internationalization 4.1.0 copy "internationalization: ^4.1.0" to clipboard
internationalization: ^4.1.0 copied to clipboard

A project to easily implement internationalization on flutter projects

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,
  ],
);
copied to clipboard

IMPORTANT!!

Don't forget to expose the JSON folders

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

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,
  parent: ['a', 'b', 'c'],
),
context.translate(
  'interpolation_string',
  parent: ['a', 'b', 'c'],
  args: ["( ͡° ͜ʖ ͡°)"],
),

context.translate(
  'interpolation_string_with_named_args',
  parent: ['a', 'b', 'c'],
  namedArgs: {"named_arg_key": "( ͡° ͜ʖ ͡°)"},
),

context.translate(
  'simple_plurals',
  parent: ['a', 'b', 'c'],
  pluralValue: 0,
),
context.translate(
  'simple_plurals',
  parent: ['a', 'b', 'c'],
  pluralValue: 1,
),
context.translate(
  'simple_plurals',
  parent: ['a', 'b', 'c'],
  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'),

"simple_string".translate()
context.translate()
copied to clipboard

NumberFormat & DateFormat #

These are features from intl library that was incoporated in Internationalization

NumberFormat DateFormat

TextIntl #

TextIntl is a Widget that can replace Text and get the translated text.

TextIntl('lblPushedTimes')
copied to clipboard
20
likes
150
points
279
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.11 - 2025.03.26

A project to easily implement internationalization on flutter projects

Repository (GitHub)

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter, flutter_localizations, intl

More

Packages that depend on internationalization