internationalization

A project to easily implement internationalization on flutter projects

MaterialApp(
  supportedLocales: _supportedLocales,
  localizationsDelegates: [
    InternationalizationDelegate(
      translationsPath: _translationsPath,
      suportedLocales: _supportedLocales,
      addTranslations: (locale) async {
        //Here you can get some external json and add to internationalization.
        //!IMPORTANTE: The json must follow the same json structure on assets.
        return {
          'external_translate': 'Translation from external source',
        };
      },      
    ),
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
);

IMPORTANT!!

Don't forget to expose the JSON folders

flutter:
  uses-material-design: true
  assets:
    - ./assets/strings/en/
    - ./assets/strings/pt/

Folder structure

The folder structure is very import. So you have to create as same as informed in pubspec.yaml

Translation

"simple_string".translate(
  context,
  translationContext: _translationContext,
),
context.translate(
  'interpolation_string',
  translationContext: _translationContext,
  args: ["( ͡° ͜ʖ ͡°)"],
),

context.translate(
  'interpolation_string_with_named_args',
  translationContext: _translationContext,
  namedArgs: {"named_arg_key": "( ͡° ͜ʖ ͡°)"},
),

context.translate(
  'simple_plurals',
  translationContext: _translationContext,
  pluralValue: 0,
),
context.translate(
  'simple_plurals',
  translationContext: _translationContext,
  pluralValue: 1,
),
context.translate(
  'simple_plurals',
  translationContext: _translationContext,
  pluralValue: 123456789,
),

context.translate(
  'interpolation_plurals',
  translationContext: _translationContext,
  pluralValue: 0,
  args: ["( ͡° ͜ʖ ͡°)"],
),
context.translate(
  'interpolation_plurals',
  translationContext: _translationContext,
  pluralValue: 1,
  args: ["( ͡° ͜ʖ ͡°)"],
),
context.translate(
  'interpolation_plurals',
  translationContext: _translationContext,
  pluralValue: 123456789,
  args: ["123456789"],
),

context.translate('no_translate_context'),

```dart
"simple_string".translate()
context.translate()

NumberFormat & DateFormat

These are features from intl library that was incoporated in Internationalization

NumberFormat DateFormat