locale_gen 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

flutter locale gen #

Dart tool that will convert your default locale json to dart code.

pub package

This repo contains an example how to use this package.

based on a package I made at icapps for the icapps translations -> https://github.com/icapps/flutter-icapps-translations

Packages used:

  • flutter_localizations
  • shared_preferences
  • provider
  • kiwi
  • locale_gen

Example #


Setup #

Add dependency to pubspec #

pub package

  locale_gen: <latest-version>

Add config to pubspec #

Add your locale folder to the assets to make use all your translations are loaded.

    - assets/locale/

Add the local_gen config to generate your dart code from json files

  default_language: 'nl'
  languages: ['en', 'nl']

if nothing is configured the following config will be used:

  default_language: 'en'
  languages: ['en']

Run package with Flutter #

flutter packages pub run locale_gen

Run package with Dart #

pub run locale_gen

Arguments #

Arguments are supported as of 0.1.0

You can pass a String or a num to as an argument.

Formatting for String: %1$s Formatting for num: %1$d

The number in between % and $ indicate the index of the argument. It is possible to place an argument in 1 language first but in another second:

ex (Grammatically incorrect but it makes my point):

nl '%1$s, ik woon in %2$s. Wist je dat niet?' => KOEN, ik woon in ANTWERPEN. Wist je dat niet?

fr 'I live in %2$s. You didn't knew that %1$s?" => I live in ANTWERP. You didn't knew that KOEN?

Working on mac? #

add this to you .bash_profile

 flutter packages get && flutter packages pub run locale_gen

now you can use the locale_gen with a single command.


Changelog #

[0.2.0] - 2019-10-13

Added #

-Test support

Fixed #

-Removed the unneeded log

[0.1.1] - 2019-08-19

Fixed #

-Fixed documentation about arguments

[0.1.0] - 2019-06-22

Added #

-Support for arguments

Fixed #

-Dart formatting

[0.0.2] - 2019-06-12

Added #

-Updated README.md

[0.0.1] - 2019-06-12

Added #

-Initial release


Example for the locale_gen #

Use this package as a library

1. Depend on it

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

  locale_gen: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

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

  • Dart: 2.7.0
  • pana: 0.13.4


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
path ^1.6.2 1.6.4
yaml ^2.1.15 2.2.0
Transitive dependencies
charcode 1.1.2
collection 1.14.12
meta 1.1.8
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
test ^1.0.0