getx_csv_translation_generator 0.0.6 getx_csv_translation_generator: ^0.0.6 copied to clipboard
GetX Translation code generator from CSV.
GetX Translation code generator from CSV.
Install #
Add the following to your pubspec.yaml:
dependencies:
getx_csv_translation: <latest>
dev_dependencies:
build_runner: <latest>
getx_csv_translation_generator: <latest>
Usage #
- Create
translations.csv
(example)
key | en_US | th_TH | <locale> |
---|---|---|---|
test | test | ทดสอบ | <translation> |
param | test @name | ทดสอบ @name | ... |
- Create
lib/translations.dart
import 'package:getx_csv_translation/getx_csv_translation.dart';
import 'package:get/get.dart';
part 'translations.g.dart';
@GetXCSVTranslation()
class GetXCSVTranslations extends Translations {
@override
Map<String, Map<String, String>> get keys => $keys;
}
-
Generate translations
3.1 with
build_runner
flutter packages pub run build_runner build
3.2 with CLI
flutter pub run getx_csv_translation_generator build --csvPath <path to translation(optional)> --targetPath <path to translations.dart(optional)>
flutter pub run getx_csv_translation_generator watch --csvPath <path to translation(optional)> --targetPath <path to translations.dart(optional)>
- Configure GetX app
return GetMaterialApp(
translations: GetXCSVTranslations(), // your translations
...
);
Build Configuraion #
Aside from setting arguments on the associated annotation classes, you can also configure code generation by setting values in build.yaml.
targets:
$default:
builders:
getx_csv_translation_generator|getx_csv_translation:
options:
# The default value for each is listed.
csv_path: ./translation.csv
single_quote: true