FLUTTER ECOSYSTEM

erf/minimal_localizations

भाषा के अनुवाद मानचित्र के साथ अपने Flutter ऐप को स्थानीयकृत करें।

minimal_localizations प्रोजेक्ट कवर
Stars
1
Forks
0
अंतिम पुश (UTC)
7 जुल॰ 2025
प्रोजेक्ट स्थिति
सक्रिय
Erlend GitHub avatar
GITHUB User

Erlend ↗

भाषाएँC++DartCMakeHTMLSwiftCKotlinObjective-C

तकनीकी विषय

इस रिपॉज़िटरी के पैकेज

उपयोग की गई निर्भरताएँ

निर्भरता सूची 4 आइटम
  • flutter{"sdk":"flutter"}
  • flutter_testडेवलपमेंट{"sdk":"flutter"}
  • flutter_localizationsडेवलपमेंट{"sdk":"flutter"}
  • flutter_lintsडेवलपमेंट^6.0.0

मूल README

यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।

README खोलें / बंद करें

minimal_localizations

Localize your Flutter app by providing a map of translations per language, along with methods to retrieve values, strings, and supported locales.

Based on the minimal localization example.

Features

  • Ideal for small projects
  • Easy to use without code generation
  • No need for assets, just pure code
  • Fast performance without asset parsing
  • Supports both String and dynamic types
  • Automatically generates supported locales
  • No external dependencies

Install

Add minimal_localizations and flutter_localizations as dependencies to your pubspec.yaml.

dependencies:
  flutter_localizations:
    sdk: flutter
  minimal_localizations:
Add translations per language

Declare MinimalLocalizationsDelegate given a map of translations per language tag.

Language tags must be valid Unicode BCP47

final minimalLocalizationsDelegate = MinimalLocalizationsDelegate({
  'en': {
    'title': 'Localizations',
    'hello': 'Hello',
  },
  'nb-NO': {
    'title': 'Lokaliseringer',
    'hello': 'Hei',
  },
});

Add localizationDelegates and set supportedLocales.

MaterialApp(
  localizationsDelegates: [
    // global delegates
    ...GlobalMaterialLocalizations.delegates,
    // minimal localizations delegate
    minimalLocalizationsDelegate,
  ],
  supportedLocales: minimalLocalizationsDelegate.supportedLocales,
}
Note on iOS

Add supported languages to ios/Runner/Info.plist as described here

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>nb-NO</string>
</array>
API

Translate dynamic values using

MinimalLocalizations.of(context).value('some_value')

Translate String values using

MinimalLocalizations.of(context).string('Hi')

We keep the API minimal, but you can easily add an extension method to String like this:

extension LocalizedString on String {
  String tr(BuildContext context) => MinimalLocalizations.of(context).string(this);
}

So you can translate String values like this:

'Hi'.tr(context)

Example

See example