generate_localized library
This provides utilities for generating localized versions of messages. It does not stand alone, but expects to be given TranslatedMessage objects and generate code for a particular locale based on them.
An example of usage can be found in test/message_extract/generate_from_json.dart
Classes
- ComplexMessage
- Abstract class for messages with internal structure, representing the main Intl.message call, plurals, and genders.
- CompositeMessage
- This represents a message chunk that is a list of multiple sub-pieces, each of which is in turn a Message.
- Gender
-
Represents a message send of
Intl.gender
inside a message that is to be internationalized. This corresponds to an ICU message syntax "select" with "male", "female", and "other" as the possible options. - IcuParser
- This defines a grammar for ICU MessageFormat syntax. Usage is new IcuParser.message.parse(
- JsonMessageGeneration
- LiteralString
- Represents a simple constant string with no dynamic elements.
- MainMessage
- Message
- An abstract superclass for Intl.message/plural/gender calls in the program's source text. We assemble these into objects that can be used to write out some translation format and can also print themselves into code.
- MessageGeneration
- Plural
- Select
-
Represents a message send of
Intl.select
inside a message that is to be internationalized. This corresponds to an ICU message syntax "select" with arbitrary options. - SubMessage
- An abstract class to represent sub-sections of a message, primarily plurals and genders.
- TranslatedMessage
- This represents a message and its translation. We assume that the translation has some identifier that allows us to figure out the original message it corresponds to, and that it may want to transform the translated text in some way, e.g. to turn whatever format the translation uses for variables into a Dart string interpolation. Specific translation mechanisms are expected to subclass this.
- VariableSubstitution
- Represents an interpolation of a variable value in a message. We expect this to be specified as an index into the list of variables, or else as the name of a variable that exists in arguments and we will compute the variable name or the index based on the value of the other.
Constants
- jsonEncoder → const JsonCodec
Functions
-
libraryName(
String x) → String - We can't use a hyphen in a Dart library name, so convert the locale separator to an underscore.
Exceptions / Errors
- IntlMessageExtractionException
- Exception thrown when we cannot process a message properly.