localization_lite 1.0.0
localization_lite: ^1.0.0 copied to clipboard
A simple package for localization by using (json).
Localization Lite #
A lightweight and simple localization package for Flutter that allows you to easily manage translations using JSON files.
Features #
- Easy setup with JSON language files.
- Lightweight and fast.
- Support for multiple languages and regions (e.g.,
en
,en_us
).
Getting Started #
- Setup: Create a new folder called
localization
in your project'sassets
directory. - Add Language Files: In the
localization
folder, 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/
Usage #
- Initialization: Initialize the translation system in your
main.dart
file:
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en");
note if you use country code the init becomes like this dart` file:
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en",withCountryCode: true);
- Access Translations: Use the
Translation
class to retrieve translated strings:
String greeting = Translation("greetingKey").toString();
Example #
Check out the /example
folder for a complete example showing how to set up and use the package.
Additional Information #
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!