native_i18n_flutter_plugin 0.1.15

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

Internationalization plugin for Flutter #

This plugin provides:

  1. i18n widgets already prepare to hold internationalized string.
  2. API to fetch internationalized strings.
  3. Command line interface that does everything for you, just need to take care of translating your app.

Getting Started #

Generate Flutter language files #

You can either generate the files manually following the naming convention strings_<locale>.json where locale is the ISO 639-1 language code or execute the following command:

flutter pub run native_i18n_flutter_plugin generateLangFiles -o <folder_for_language_files> -i <language_code_comma_separated

The first language specified will be set to be the default.

Example #

flutter pub run native_i18n_flutter_plugin generateLangFiles -o lang -i en,es,de

Generate native language files #

In order to have it ready, you need to generate the language files for each platform, therefore, you need to run the following command:

flutter pub run native_i18n_flutter_plugin generateNative -i <folder_for_flutter_language_files> [--watch]

The command above will generate the necessary files for each platform (check Supported Platforms) although there are extra steps you need to follow you can use it.

Android #

No extra steps needed, it works out-of-the-box

iOS #

If you have included a new language in your app, you need to add the localize file into the building process, therefore, you have to do the following:

  1. Open Runner.xcworkspace file with XCode

  2. In the project overview, you need to right click on the Runner folder and then click on Add files to "Runner" option

  3. Inside of the Runner folder, there are one folder per language with the following format <locale>.lproj so you need to add each file inside of that folder so when Flutter builds your app, those file will be included as well.

Generate Dart class with keys as static properties #

Sometimes is hard to remember all the keys, so what if the IDE you are using to create your app can remind you those keys. That's what this command is for, so just run the following command and enjoy the magic:

flutter pub run native_i18n_flutter_plugin generateClass -i <folder_for_flutter_language_files> -o <location_for_your_class> [--watch]

Generate Dart class and Native files with only one command #

If you want to generate everything just with one command, here it is:

flutter pub run native_i18n_flutter_plugin generate -i <folder_for_flutter_language_files> -o <location_for_your_class> [--watch]


  1. Generate class containing the language strings keys so can be used with IDE autocompletion. ✅
  2. Formatted strings. ✅
  3. Added watch flag so the command line will run whenever a file is change. ✅
  4. Strings pluralization.

Known issues #

App crashes as soon as tries to load a translation on Android #

There is a problem deserializing the data sent to the native language API due to shrinkResources feature, therefore, until a solution is found you need to disable when you generate a release.

0.1.0 #

First published release

0.1.1 #

Fix minor formatting issues

0.1.2 #

Change cli for generating language files as currently there is a bug on Flutter pub run preventing to work more interactively: []

0.1.3 #

Use a widget builder instead of a predefined widget.

0.1.4 #

Fix command line name for native files generation.

0.1.5 #

Fix bug due to have not change all the occurrences for the native file generation command

0.1.6 #

Fix bug in command line with projects that haven't been set up yet.

0.1.7 #

Nested JSON keys are supported in language files.

0.1.8 #

Code refactoring for native files generation.

0.1.9 #

New CLI command available to generate both Native files and I18n Dart class.

0.1.10 #

Fix bug running dartfmt on Windows.

0.1.11 #

Cache added to prevent doing so many calls.

0.1.12 #

Checks whether a translation is returned as null

0.1.13 #

Solving problem deserializing translations when build a release

0.1.15 #

Solving problem with Kotlin compilation


i18n_plugin_example #

Demonstrates how to use the i18n_plugin plugin.

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:

  native_i18n_flutter_plugin: ^0.1.15

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:native_i18n_flutter_plugin/native_i18n_flutter_plugin.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 Jan 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/native_i18n_flutter_plugin.dart.

Run flutter format to format lib/native_i18n_flutter_plugin.dart.

Format lib/runner/generators/file_generator.dart.

Run flutter format to format lib/runner/generators/file_generator.dart.

Format lib/runner/generators/language_file_generator.dart.

Run flutter format to format lib/runner/generators/language_file_generator.dart.

Fix additional 7 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/runner/generators/language_string_class_generator.dart (Run flutter format to format lib/runner/generators/language_string_class_generator.dart.)
  • lib/runner/generators/native_files_generator.dart (Run flutter format to format lib/runner/generators/native_files_generator.dart.)
  • lib/runner/helpers/language_file.dart (Run flutter format to format lib/runner/helpers/language_file.dart.)
  • lib/runner/helpers/language_string_map.dart (Run flutter format to format lib/runner/helpers/language_string_map.dart.)
  • lib/runner/i18_cli_app.dart (Run flutter format to format lib/runner/i18_cli_app.dart.)
  • lib/translation.dart (Run flutter format to format lib/translation.dart.)
  • lib/widgets/i18n_widget_builder.dart (Run flutter format to format lib/widgets/i18n_widget_builder.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (logger).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
args ^1.5.2 1.5.2
dcache ^0.3.0 0.3.0
flutter 0.0.0
logger ^0.7.0+2 0.7.0+2 0.8.3
path ^1.6.0 1.6.4
process_run ^0.10.2 0.10.7
sprintf ^4.0.2 4.0.2
watcher ^0.9.7+12 0.9.7+13
xml ^3.5.0 3.7.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
io 0.3.3
meta 1.1.8
pedantic 1.9.0
petitparser 3.0.0
pub_semver 1.4.2
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
yaml 2.2.0
Dev dependencies
analyzer ^0.37.0