Name Description Size
__init__.py 129
_context.py Internal context for merging translation resources. For the public interface, see `context.MigrationContext`. 12890
blame.py 2493
changesets.py Order two changesets by their first commit date. 1777
context.py Stateful context for merging translation resources. `MigrationContext` must be configured with the target locale and the directory locations of the input data. The transformation takes four types of input data: - The en-US FTL reference files which will be used as templates for message order, comments and sections. If the reference_dir is None, the migration will create Messages and Terms in the order given by the transforms. - The current FTL files for the given locale. - A list of `FTL.Message` or `FTL.Term` objects some of whose nodes are special helper or transform nodes: helpers: VARIABLE_REFERENCE, MESSAGE_REFERENCE, TERM_REFERENCE transforms: COPY, REPLACE_IN_TEXT, REPLACE, PLURALS, CONCAT fluent value helper: COPY_PATTERN The legacy (DTD, properties) translation files are deduced by the dependencies in the transforms. The translations from these files will be read from the localization_dir and transformed into FTL and merged into the existing FTL files for the given language. 6311
errors.py 313
evaluator.py An AST transformer for evaluating migration Transforms. An AST transformer (i.e. a visitor capable of modifying the AST) which walks an AST hierarchy and evaluates nodes which are migration Transforms. 859
helpers.py Fluent AST helpers. The functions defined in this module offer a shorthand for defining common AST nodes. They take a string argument and immediately return a corresponding AST node. (As opposed to Transforms which are AST nodes on their own and only return the migrated AST nodes when they are evaluated by a MigrationContext.) 6192
merge.py Transform legacy translations into FTL. Use the `reference` FTL AST as a template. For each en-US string in the reference, first check for an existing translation in the current FTL `localization` and use it if it's present; then if the string has a transform defined in the migration specification and if it's in the currently processed changeset, evaluate the transform. 1808
repo_client.py Wrapper for calling command-line git in the `root` directory. Raises an exception on any error, including a non-0 return code. Returns the command's stdout as a string. 3528
tool.py Run the migration for the changeset, with the set of this and all prior legacy translations. 5894
transforms.py Migration Transforms. Transforms are AST nodes which describe how legacy translations should be migrated. They are created inert and only return the migrated AST nodes when they are evaluated by a MigrationContext. All Transforms evaluate to Fluent Patterns. This makes them suitable for defining migrations of values of message, attributes and variants. The special CONCAT Transform is capable of joining multiple Patterns returned by evaluating other Transforms into a single Pattern. It can also concatenate Pattern elements: TextElements and Placeables. The COPY, REPLACE and PLURALS Transforms inherit from Source which is a special AST Node defining the location (the file path and the id) of the legacy translation. During the migration, the current MigrationContext scans the migration spec for Source nodes and extracts the information about all legacy translations being migrated. For instance, COPY('file.dtd', 'hello') is equivalent to: FTL.Pattern([ Source('file.dtd', 'hello') ]) Sometimes it's useful to work with text rather than (path, key) source definitions. This is the case when the migrated translation requires some hardcoded text, e.g. <a> and </a> when multiple translations become a single one with a DOM overlay. In such cases it's best to use FTL.TextElements: FTL.Message( id=FTL.Identifier('update-failed'), value=CONCAT( COPY('aboutDialog.dtd', 'update.failed.start'), FTL.TextElement('<a>'), COPY('aboutDialog.dtd', 'update.failed.linkText'), FTL.TextElement('</a>'), COPY('aboutDialog.dtd', 'update.failed.end'), ) ) The REPLACE_IN_TEXT Transform also takes TextElements as input, making it possible to pass it as the foreach function of the PLURALS Transform. In the example below, each slice of the plural string is converted into a TextElement by PLURALS and then run through the REPLACE_IN_TEXT transform. FTL.Message( FTL.Identifier('delete-all'), value=PLURALS( 'aboutDownloads.dtd', 'deleteAll', VARIABLE_REFERENCE('num'), lambda text: REPLACE_IN_TEXT( text, { '#1': VARIABLE_REFERENCE('num') } ) ) ) 20692
util.py Get message called `ident` from the `body` iterable. 2853
validator.py Validate a migration recipe Extract information from the migration recipe about which files to migrate from, and which files to migrate to. Also check for errors in the recipe, or bad API usage. 11020