sheets_i18n 0.0.1+2
sheets_i18n: ^0.0.1+2 copied to clipboard
A flutter tool to synchronize i18n (internationalization) arb files with google sheets.
sheets_i18n #
A flutter tool to synchronize i18n (internationalization) arb files with google sheets.
Usage #
1. Prepare a Google Sheet Document #
You can get the sample here: docs.google.com
It should look like this:
- the first column is the message key (used to lookup the translation in the app).
- the columns after that are the language codes.
- the rows are for each specific translated word/sentence.
2. Configure a service account #
- Create a new service account in the Google Cloud Console
- Turn on the Google Sheets API
- Copy the service account's email address
- Share the google sheet with the service account and give it edit privileges
- Download the service account JSON (it's local path will later be added to the pubspec configuration)
3. Prerequisites with intl_translation #
- Having setup
intl_translation, incl. aMyAppLocalizationsandMyAppLocalizationsDelegateclass - Having run the
intl_translationcommands to generate the arb files github.com/dart-lang/i18n
4. Install this package #
flutter pub add sheets_i18n
5. Configure the pubspec.yaml #
add this section:
sheets_i18n:
service_account_path: ./service_account.json
sheet_id: 34tv34rv324rv23rv3r43r43red89f8hs89duzfs
6. Run the sync script #
flutter pub run sheets_i18n:update
This will 2-way-sync all the changes:
- message keys that are not present in the Google Sheet will be added
- new translations will be pulled and written to the arb files
7. Run intl_translation's arb to dart #
Run the intl_translation commands to generate the dart code from the arb files github.com/dart-lang/i18n