internationalization 2.0.0

internationalization #

A project to easily implement internationalization on flutter projects

Configure Internationalization #

Create a yaml file named internationalization then do the configurations like this:

path: ./assets/strings
  language: en
  country: US
  - locale:
      language: pt
  - locale:
      language: en
      country: US
  • path -> where JSON files (strings) were placed
  • default_locale -> default strings
  • locales -> Array of locales

Now import internationalization package on main.dart.

import 'package:internationalization/internationalization.dart';

Make void main() async then load internationalization configurations

void main() async {
  await Internationalization.loadConfigurations();

Pass the delegates to localizationsDelegates.

Widget build(BuildContext context) {
    return MaterialApp(
        supportedLocales: suportedLocales,
        localizationsDelegates: [

In pubspec.yaml put the path that you've passed to InternationalizationDelegate and the configuration file

    - ./assets/strings/
    - ./internationalization.yaml

Usage #

Strings.of(context).valueOf("key") //To get a simple string
Strings.of(context).valueOf("key", args: ["A", "B", "C"]) //To get an interpoled string
Strings.of(context).pluralOf("key", 0) //To get a plural string
Strings.of(context).pluralOf("key", 0, args: ["A", "B", "C"]) //To get a plural interpoled string
Strings.of(context).valueOf("key", args: ["A", "B", "C"], namedArgs: {"named_arg_key": "Named arg"}) //To get an interpoled name string

JSON file #

Crete JSON files with locale language code and country code. Ex.: pt.json, en_US.json, etc... Note: create JSON files inside folder you passed to InternationalizationDelegate

    "simple_string": "Simple string value",
    "interpolation_string": "Interpoleted {0} string {1}",
    "simple_plurals" : {
        "zero": "No information",
        "one": "A item",
        "other": "Many itens"
    "interpolation_plurals": {
        "zero": "No information {0} with {1}",
        "one": "A item {0} with {1}",
        "other": "Many itens {0} with {1}"
    "interpolation_string_with_named_args": "Interpoleted {0} string with ::named_arg_key::"

[2.0.0] (October 1, 2019)

  • Configurations via yaml file

[1.2.0] (Agust 16, 2019)

  • Removed need to pass country code

[1.1.0+1] (Agust 16, 2019)

  • README example for named interpolation

[1.1.0] (Agust 16, 2019)

  • Added suport for named interpolation

[1.0.1] (Agust 6, 2019)

  • Null safety for locales

[1.0.0+1] (July 27, 2019)

  • Refactor code

[1.0.0] (July 25, 2019)

  • Initial release


internationalization_example #

A example project for internationalization

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  internationalization: ^2.0.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:internationalization/internationalization.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 18, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health issues and suggestions

Document public APIs. (-1 points)

10 out of 10 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/internationalization.dart.

Run flutter format to format lib/internationalization.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_localizations 0.0.0
yaml ^2.1.16 2.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
intl 0.16.0 0.16.1
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8