<commit_before>#!/usr/bin/env dart
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/**
 * This simulates a translation process, reading the messages generated
 * from extract_message.dart for the files sample_with_messages.dart and
 * part_of_sample_with_messages.dart and writing out hard-coded translations for
 * German and French locales.
 */

import 'dart:io';
import 'dart:json' as json;
import 'package:path/path.dart' as path;
import 'package:args/args.dart';
import 'package:intl/src/intl_message.dart';
import 'package:serialization/serialization.dart';

/**
 * A serialization so that we can write out the more complex plural and
 * gender examples to JSON easily. This is a stopgap and should be replaced
 * with a commonly used translation file format.
 */
get serialization => new Serialization()
  ..addRuleFor(new VariableSubstitution(0, null),
      constructorFields: ["index", "parent"])
  ..addRuleFor(new LiteralString("a", null),
      constructorFields: ["string", "parent"])
  ..addRuleFor(new CompositeMessage([], null), constructor: "parent",
      constructorFields: ["parent"]);
var format = const SimpleFlatFormat();
get writer => serialization.newWriter(format);

/** A list of the French translations that we will produce. */
var french = {
  "types" : r"$a, $b, $c",
  "multiLine" : "Cette message prend plusiers lignes.",
  "message2" : r"Un autre message avec un seul paramètre $x",
  "alwaysTranslated" : "Cette chaîne est toujours traduit",
  "message1" : "Il s'agit d'un message",
  "leadingQuotes" : "\"Soi-disant\"",
  "trickyInterpolation" : r"L'interpolation est délicate "
    r"quand elle se termine une phrase comme ${s}.",
  "message3" : "Caractères qui doivent être échapper, par exemple barres \\ "
    "dollars \${ (les accolades sont ok), et xml/html réservés <& et "
    "des citations \" "
    "avec quelques paramètres ainsi \$a, \$b, et \$c",
  "method" : "Cela vient d'une méthode",
  "nonLambda" : "Cette méthode n'est pas un lambda",
  "staticMessage" : "Cela vient d'une méthode statique",
  "notAlwaysTranslated" : "Ce manque certaines traductions",
  "thisNameIsNotInTheOriginal" : "Could this lead to something malicious?",
  "originalNotInBMP" : "Anciens caractères grecs jeux du pendu: 𐅆𐅇.",
  "escapable" : "Escapes: \n\r\f\b\t\v.",
  "plurals" : writer.write(new Plural.from("num",
      [
        ["zero", "Est-ce que nulle est pluriel?"],<commit_msg>Fix message_extraction test.<commit_after>#!/usr/bin/env dart
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/**
 * This simulates a translation process, reading the messages generated
 * from extract_message.dart for the files sample_with_messages.dart and
 * part_of_sample_with_messages.dart and writing out hard-coded translations for
 * German and French locales.
 */

import 'dart:io';
import 'dart:json' as json;
import 'package:path/path.dart' as path;
import 'package:args/args.dart';
import 'package:intl/src/intl_message.dart';
import 'package:serialization/serialization.dart';

/**
 * A serialization so that we can write out the more complex plural and
 * gender examples to JSON easily. This is a stopgap and should be replaced
 * with a commonly used translation file format.
 */
get serialization => new Serialization()
  ..addRuleFor(new VariableSubstitution(0, null),
      constructorFields: ["index", "parent"])
  ..addRuleFor(new LiteralString("a", null),
      constructorFields: ["string", "parent"])
  ..addRuleFor(new CompositeMessage([], null), constructor: "withParent",
      constructorFields: ["parent"]);
var format = const SimpleFlatFormat();
get writer => serialization.newWriter(format);

/** A list of the French translations that we will produce. */
var french = {
  "types" : r"$a, $b, $c",
  "multiLine" : "Cette message prend plusiers lignes.",
  "message2" : r"Un autre message avec un seul paramètre $x",
  "alwaysTranslated" : "Cette chaîne est toujours traduit",
  "message1" : "Il s'agit d'un message",
  "leadingQuotes" : "\"Soi-disant\"",
  "trickyInterpolation" : r"L'interpolation est délicate "
    r"quand elle se termine une phrase comme ${s}.",
  "message3" : "Caractères qui doivent être échapper, par exemple barres \\ "
    "dollars \${ (les accolades sont ok), et xml/html réservés <& et "
    "des citations \" "
    "avec quelques paramètres ainsi \$a, \$b, et \$c",
  "method" : "Cela vient d'une méthode",
  "nonLambda" : "Cette méthode n'est pas un lambda",
  "staticMessage" : "Cela vient d'une méthode statique",
  "notAlwaysTranslated" : "Ce manque certaines traductions",
  "thisNameIsNotInTheOriginal" : "Could this lead to something malicious?",
  "originalNotInBMP" : "Anciens caractères grecs jeux du pendu: 𐅆𐅇.",
  "escapable" : "Escapes: \n\r\f\b\t\v.",
  "plurals" : writer.write(new Plural.from("num",
      [
        ["zero", "Est-ce que nulle est pluriel?"],
{'fraction_non_alphanumeric': 0.12738485257275003, 'fraction_numerical': 0.0030834457506263247, 'mean_word_length': 4.26369168356998, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6987038', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1664, 'n_words': 557}