I can get value of translations with methods like that :
AppLocalizations.of(context).closed
if I have "closed" as String variable like that :
String c = "closed";
how can I get the value with c Variable :
AppLocalizations.of(context).c ( This Makes Error "The getter 'c' isn't defined for the type 'AppLocalizations'")
I followed the Flutter official doc for Internationalization, but I haved the same problem. So, I have installed on my ide (Visual Studio Code) the plugin Flutter Intl (localizely.flutter-intl), it's available also in Android Studio. To get the dynamic tranlsations, I haved use the ICU format type called: Select (https://support.crowdin.com/icu-message-syntax/#select). For example:
main.dart
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
init_it.arb
"gender": "{gender, select, male{Maschio} female{Femmina} other{entrambi}}",
"@gender": {
"description": "Gender type",
"placeholders": {
"gender": {}
}
}
myWidget.dart
Text(
S.of(context).gender(gender.name)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With