Skip to content

Latest commit

 

History

History

example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Example

In this example the two files in /assets/langs directory

assets/langs/it.json
{
    "HELLO": "Hi!",
    "ERROR": {
        "WRONG_USERNAME": "Wrong username",
        "WRONG_PASSWORD": "Wrong password"
    },
    "OTHER_LABEL": "Only in english"
}
assets/langs/en.json
{
    "HELLO": "Ciao!",
    "ERROR": {
        "WRONG_USERNAME": "Username errato",
        "WRONG_PASSWORD": "Password errata"
    }
}

will be parsed and the translations_keychain.dart file in /lib/i18n will be generated.

// GENERATED CODE - DO NOT MODIFY BY HAND

// **************************************************************************
// TranslationsKeychain
// **************************************************************************

abstract class TranslationsKeychain {
  static const ERROR_WRONG_PASSWORD = 'ERROR.WRONG_PASSWORD';
  static const ERROR_WRONG_USERNAME = 'ERROR.WRONG_USERNAME';
  static const HELLO = 'HELLO';
  static const OTHER_LABEL = 'OTHER_LABEL';
}

So you could avoid to write the translation's label by hand, but you could use it with:

void main() {
  print(TranslationsKeychain.HELLO);
}