arb_generator 0.0.1
arb_generator: ^0.0.1 copied to clipboard

A dart tool which generates ARB files from CSV files.

arb_generator #

A dart tool which generates ARB files from CSV files.

Getting Started #

A CSV file of the form

keysdescriptionende
myKeyThe conventional newborn programmer greetingHello world!Hallo Welt!
welcomeA welcome messageWelcome {firstName}!Willkommen {firstName}!
numberMessagesAn info message about new messages count{count, plural, zero{You have no new messages} one{You have 1 new message} other{You have {count} new messages}}{count, plural, zero{Du hast keine neue Nachrichten} one{Du hast eine neue Nachricht} other{Du hast {count} neue Nachrichten}}
whoseBookA message determine whose book it is{sex, select, male{His book} female{Her book} other{Their book}}{sex, select, male{Sein Buch} female{Ihr Buch} other{Ihr Buch}}

is generated into the following ARB file

{
  "@@locale": "en",
  "myKey": "Hello world!",
  "@myKey": {
    "description": "The conventional newborn programmer greeting"
  },
  "welcome": "Welcome {firstName}!",
  "@welcome": {
    "description": "A welcome message"
  },
  "numberMessages": "{count, plural, zero{You have no new messages} one{You have 1 new message} other{You have {count} new messages}}",
  "@numberMessages": {
    "description": "An info message about new messages count"
  },
  "whoseBook": "{sex, select, male{His book} female{Her book} other{Their book}}",
  "@whoseBook": {
    "description": "A message determine whose book it is"
  }
}

This ARB file can then be converted into localization delegates using, for instance, intl_utils.

Add dependency #

Firstly, add the package as a dev dependency:

dev_dependencies: 
  arb_generator:

Note that arb_generator requires dart sdk >= 2.12.

Define Settings #

Next define arb_generator package settings in pubspec.yaml. Note that input_filepath is the only required parameter.

arb_generator:
  input_filepath: "assets_dev/test.csv"
  output_filepath: "lib/l10n"
  filename_prepend: "intl_"
  csv_settings:
    delimiter: ";"
    description_index: 1
    base_index: 2
SettingDescription
input_filepathRequired. A path to the input CSV file.
output_dirA directory to generate the output ARB file(s). Defaults to lib/l10
filename_prependText to prepend to filename of generated files. Fefaults to empty string.
csv_settings: delimiterA delimiter to separate columns in the input CSV file. Defaults to ,.
csv_settings: description_indexThe description column index. Defaults to null.
csv_settings: base_indexThe column index of the base language in the input CSV file. Defaults to 1.

Run package #

Ensure that your current working directory is the project root. Depending on your project, run one of the following commands:

dart run flutter_pseudolocalizor

or

flutter pub run flutter_pseudolocalizor

ARB files are then generated in output_dir.

Collaboration #

Spotted any issues? Please open an issue on GitHub! Would like to contribute a new language or feature? Fork the repo and submit a PR!

2
likes
110
pub points
20%
popularity

Publisher

defuncart.com

A dart tool which generates ARB files from CSV files.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flappy_translator, yaml

More

Packages that depend on arb_generator