Developer
Localization
Localization for mobile app with versioning. Localization is based on intl package.
Installation
dart pub global activate eit_translation --hosted-url=https://gitea.whitelabel.mobile.embedit.dev/api/packages/platform/pub/
!IMPORTANT You need access token for fetching from private pub repository. ELI add token automatically
Usage
MaterialApp.router(
localizationsDelegates: localizationsDelegates,
supportedLocales: supportedLocales,
onGenerateTitle: (context) => context.tr.appName,
);
How to add new Locale
- Create new file
intl_cs.arb
orintl_cs_CZ.arb
in folderlib/l10n
├── lib
│ ├── l10n
│ │ ├── intl_en.arb
│ │ ├── intl_cs.arb
│ ├── ...
└── ...
- update
lib/delegates.dart
const supportedLocales = [
Locale('en'),
Locale('cs'),
];
- Adding Supported Locales
Update the CFBundleLocalizations
array in the Info.plist
at ios/Runner/Info.plist
to include the new locale.
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
How to modify translations
- Edit
lib/l10n/intl_en.arb
- Then add a new key/value and description
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- Run generator
- Use the new string
import 'package:mobi_translate/mobi_translate.dart';
@override
Widget build(BuildContext context) {
// use BuildContext extension `tr`
return Text(context.tr.helloWorld);
}
Run generator
in root of the project use
flutter pub run intl_utils:generate