Skip to content

doloc-io/flutter-doloc-demo

Repository files navigation

Demo for using doloc.io with flutter

This is a simple demo for using doloc.io with Flutter.

It is recommended to follow our dedicated guide for Flutter to get started.

Pre-requisites

To update the translations, you need to set the API_TOKEN environment variable to your doloc.io API token. You can get a free API token by signing up at doloc.io.

export API_TOKEN=YOUR_API_TOKEN

Running the demo

This demo can be run on an emulator or a physical device.

The easiest way to run the demo is to use the flutter run command:

flutter run -d chrome

Generally, the Flutter runtime selects the language based on the device's language settings. For testing different locales, please refer to Flutter Localization Testing. When running the app in Chrome, you can override the locale in the DevTools "Sensors" tab.

Adding translations

You can add new strings manually to lib/l10n/app_en.arb or use the Flutter localization tools. If you use the integrated tools, make sure to not add the new string resource to translated files (lib/l10n/app_de.arb).

An example could be:

{
  "your_id": "some new string"
}

After adding the new message, you need to run doloc to translate and add it to the translated files. This demo shows two alternative paths:

  • Local workflow: the plain Dart script for local development.
  • CI workflow: the doloc-io/doloc-action@v1 GitHub Action for automation.

Local workflow

Run the plain Dart script to translate the new message locally:

export API_TOKEN=YOUR_API_TOKEN
dart run tool/doloc.dart

Observe that the new message is added to lib/l10n/app_de.arb and already translated!

CI workflow

If you are using the CI workflow, you can simply push your changes to the repository. Check out the workflow definition in .github/workflows/localization.yml to see how doloc-io/doloc-action@v1 updates the translations.

When your change is merged into the main branch, the translations will be updated automatically and a new commit will be created with the updated translations.

Note: This workflow expects the DOLOC_API_TOKEN to be set as a secret in your repository.

About

Demo for using doloc.io with flutter

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors