A lightweight and simple localization package for Flutter that allows you to easily manage translations using JSON files.
- 🔎 Automatically detects and applies device language settings
- 📝 Easy setup with JSON language files.
- ⚡ Lightweight and fast.
- 🌍 Support for multiple languages without regions for more simplicity (e.g.,
en,ar... ).
- Setup: Create a new folder called
localizationin your project'sassetsdirectory. - Add Language Files: In the
localizationfolder, add JSON files for each language you want to support (e.g.,en.json,ar.json). - Configure Assets: Add the localization files to your
pubspec.yaml:dependencies: localization_lite: ^latest_version flutter: assets: - assets/localization/
- Initialization: Initialize the translation system in your
main.dartfile:
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en");📝 note You can also add a custom
pathto the json by adding the path argument to theinitfn. But when add custom path don't forget to add it to thepubspec.yaml dartfile:
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en",path: "myCustomPath"); flutter:
assets:
- myCustomPath/- Access Translations: Use the
Translationclass to retrieve translated strings:
String greeting = Translation("greetingKey").toString();or
String greeting = tr("greetingKey");Check out the /example folder for a complete example showing how to set up and use the package.
For more information on contributing, filing issues, or requesting new features, please check the GitHub repository. Contributions are welcome, and any feedback or improvements are appreciated!
