Do you know any way to do this?
For example
en.json
{
"title": "Hello",
"home.msg": "Hello {} in the {} world ",
...
}
l10n_keys.dart
class LocalizationKeys{
static const String titile = 'title';
static const String home_msg = 'home.msg';
}
@basketball-ico currently no
Hi @basketball-ico and @aissat ,
I'm using easy_localization in some Flutter apps, and I would like to have that useful abstract class.
So I'm started to working on a build_runner task to do exactly this job, and I release the first version on yesterday.
The package is translations_keychain.
With that tool you could use the translations label with:
Text(TranslationsKeychain.title.tr());
I hope it could helps. :)
--Luca
@lcaprini Thanks! we already release code generation for json/csv, please look develop branch. If you have any suggestions, this will help us.
@Overman775 Cool! I saw the code generation, but I think it is a different thing.
My generator is only for the keys, it doesn't consider the translations: it generates a simple abstract class with all the keys of the translation files as property, so you could use it in order to have IDE suggestions instead to write manually.
In example, instead to write Text('HOME'.tr()) you could use Text(TranslationsKeychain.HOME.tr());.
I used your json generator, and I think is useful, but I don't find a way that helps the IDE to suggest me the key. Maybe I missed something?
@lcaprini Now I understand, thanks for the good idea 馃憤
@basketball-ico @lcaprini
dependencies:
easy_localization: ^2.2.0-dev
example:
{
"msg_named": "{} 賲賰鬲賵亘丞 亘丕賱賱睾丞 {lang}",
}
flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart
```
abstract class LocaleKeys {
static const msg_named = 'msg_named';
}
```dart
Text(LocaleKeys.msg_named).tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),
Most helpful comment
Hi @basketball-ico and @aissat ,
I'm using
easy_localizationin some Flutter apps, and I would like to have that useful abstract class.So I'm started to working on a
build_runnertask to do exactly this job, and I release the first version on yesterday.The package is translations_keychain.
With that tool you could use the translations label with:
I hope it could helps. :)
--Luca