Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

L10n (Localization)

Jonas Wanke edited this page Apr 8, 2021 · 2 revisions

When showing strings to the user, these should usually be translated into that user's language. (We currently support English and German.) To translate these strings, we store localized (≈ translated) variants of that as .arb-files (based on JSON): lib/l10n/l10n_<locale>.arb. Those strings are then moved into a generated Dart class, which you can access as context.s.my_string_key.

The naming should roughly follow existing keys: <module>_<widget>_<customIdentifier>.

When you're done editing an .arb-file, some Dart files need to be re-generated using Flutter Intl. Sometimes that happens automatically, but if context.s.my_string_key is not available, try:

  1. Opening the modified lib/l10n/l10n_<locale>.arb-file(s) and hitting save. This should trigger the generator (when using VS Code and the Flutter Intl).
  2. Opening lib/generated/l10n.dart. This file contains the generated strings and by opening it VS Code sees its updated contents.
Clone this wiki locally