https://github.com/hesham04dev/localization_lite
A package in dart for localization
https://github.com/hesham04dev/localization_lite
dart flutter keepitsimple localization
Last synced: about 1 year ago
JSON representation
A package in dart for localization
- Host: GitHub
- URL: https://github.com/hesham04dev/localization_lite
- Owner: hesham04Dev
- License: mit
- Created: 2024-10-14T10:44:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-26T08:24:21.000Z (over 1 year ago)
- Last Synced: 2024-10-29T10:19:55.431Z (over 1 year ago)
- Topics: dart, flutter, keepitsimple, localization
- Language: Dart
- Homepage: https://pub.dev/packages/localization_lite
- Size: 43.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
#
Localization Lite
A lightweight and simple localization package for Flutter that allows you to easily manage translations using JSON files.
## β¨ Features
- π 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` ... ).
## π Getting Started
1. **Setup**: Create a new folder called `localization` in your project's `assets` directory.
2. **Add Language Files**: In the `localization` folder, add JSON files for each language you want to support (e.g., `en.json` , `ar.json`).
3. **Configure Assets**: Add the localization files to your `pubspec.yaml`:
```yaml
dependencies:
localization_lite: ^latest_version
flutter:
assets:
- assets/localization/
```
## π Usage
1. Initialization: Initialize the translation system in your `main.dart` file:
```dart
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en");
```
> π note You can also add a custom `path` to the json by adding the path argument to the `init` fn. But when add custom path don't forget to add it to the `pubspec.yaml
dart` file:
```dart
await WidgetsFlutterBinding.ensureInitialized();
await Translation.init(defaultLang: "en",path: "myCustomPath");
```
```yaml
flutter:
assets:
- myCustomPath/
```
2. Access Translations: Use the `Translation` class to retrieve translated strings:
```dart
String greeting = Translation("greetingKey").toString();
```
or
```dart
String greeting = tr("greetingKey");
```
## π‘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](https://github.com/hesham04Dev/localization_lite). Contributions are welcome, and any feedback or improvements are appreciated!