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

  1. Create new file intl_cs.arb or intl_cs_CZ.arb in folder lib/l10n
├── lib
│   ├── l10n
│   │   ├── intl_en.arb
│   │   ├── intl_cs.arb
│   ├── ...
└── ...
  1. update lib/delegates.dart
const supportedLocales = [
    Locale('en'),
    Locale('cs'),
];
  1. 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

  1. Edit lib/l10n/intl_en.arb
  2. 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"
    }
}
  1. Run generator
  2. 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

Copyright © 2025. All rights reserved.