Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lcaprini/translations_keychain
A Dart builder to convert the JSON translation files into an abstract class for label suggestions
https://github.com/lcaprini/translations_keychain
builder builder-generator dart flutter i18n
Last synced: 30 days ago
JSON representation
A Dart builder to convert the JSON translation files into an abstract class for label suggestions
- Host: GitHub
- URL: https://github.com/lcaprini/translations_keychain
- Owner: lcaprini
- License: mit
- Created: 2020-04-16T18:18:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-18T11:47:40.000Z (almost 5 years ago)
- Last Synced: 2024-03-18T19:35:06.973Z (11 months ago)
- Topics: builder, builder-generator, dart, flutter, i18n
- Language: Dart
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# translations_keychain
`translations_keychain` is a small Dart builder that converts the local JSON files used for translations into a Dart abstract class.
When `translations_keychain` is running in watch mode, you could simply edit your JSON file and the abstract class will be automatically updated.
### Features
- [x] Merges all JSON keys in one single file
- [x] Supports for nested JSON objects for grouped labels
- [x] Sorts the final class properties
- [x] Use UpperCamelCase for class name and snake_case for file name## Getting Started
### Install
Add this to your package's pubspec.yaml file:
```yaml
dev_dependencies:
# stable version install from https://pub.dev/packages
translations_keychain:
build_runner: ^1.8.1# Dev version install from git REPO
translations_keychain:
git: https://github.com/lcaprini/translations_keychain.git
```### Configure
By default `translations_keychain` scans every JSON file into the `/assets/langs` directory and generates the `translations_keychain.dart` file into `/lib/i18n`
directory.If you want to change the default behaviour you could create or update the `build.yaml` file of your project with:
```yaml
targets:
$default:
builders:
translations_keychain:
options:
path:
output:
class_name:
```### Use with Dart
With `build_runner` installed, you could semply launch the `build` task
```bash
pub run build_runner build --delete-conflicting-outputs
```or launch in `watch` mode if you want to update the final class file automagically.
```bash
pub run build_runner watch --delete-conflicting-outputs
```### Use with Flutter
Of course this package could be used also in a flutter app; the `build_runner` tasks became:
```bash
flutter pub run build_runner build --delete-conflicting-outputsflutter pub run build_runner watch --delete-conflicting-outputs
```### Example
- [Source code](example)
An example showing how to setup and use `translations_keychain`.