easy_localization_sheet 1.0.2 easy_localization_sheet: ^1.0.2 copied to clipboard
A tool to help generate json from csv file. It is useful when used with localization packages.
easy_localization_sheet #
Download the csv file and generate json files for easy_localization or any package that supports localization from json. This package generates json files only. Let your localization package do the rest with generated files.
Installation #
Add to your project:
dart pub add --dev easy_localization_sheet
or dart pub add --dev easy_localization_sheet
Your pubspec.yaml
will look like below:
dependencies:
...
dev_dependencies:
...
easy_localization_sheet: <last_version>
Usage #
Add below section to your pubspec.yaml
easy_localization_sheet:
csv_url: 'your url'
output_dir: 'assets/translations' # Optional, default is assets
easy_localization_generate: # For use easy_localization:generate command, remove this block to disable
output_dir: lib/generated
output_file_name: locale_keys.g.dart
Then run dart run easy_localization_sheet
or flutter pub run easy_localization_sheet
Example #
Google sheet example:
- Make google sheet public
- Extract
SHEET_ID
from Google sheet url:https://docs.google.com/spreadsheets/d/{SHEET_ID}/edit#gid=0
- Set
csv_url: 'https://docs.google.com/spreadsheets/d/{YOUR_ID}/export?format=csv'
- Run
dart run easy_localization_sheet
Syntax #
key
column is required, row containskey
also called header.- Rows above header will be ignored
- Ignore column should be put into
()
, example(your column name)
- Nested keys
# key name
gender.male
gender.female
# generated json
"gender": {
"male": "Male",
"female": "Female"
}