Add localizations system
This commit is contained in:
parent
4f4e3a4df5
commit
1f230c0a63
12 changed files with 437 additions and 18 deletions
31
README.md
31
README.md
|
|
@ -23,3 +23,34 @@ Community: [#fluffychat:matrix.org](https://matrix.to/#/#fluffychat:matrix.org)
|
|||
4. `flutter config --enable-web`
|
||||
|
||||
5. `flutter run`
|
||||
|
||||
## How to add translations for your language
|
||||
|
||||
1. Replace the non-translated string in the codebase:
|
||||
```
|
||||
Text("Hello world"),
|
||||
```
|
||||
with a method call:
|
||||
```
|
||||
Text(I18n.of(context).helloWorld),
|
||||
```
|
||||
And add the method to `/lib/i18n/i18n.dart`:
|
||||
```
|
||||
String get helloWorld => Intl.message('Hello world');
|
||||
```
|
||||
|
||||
2. Add the string to the .arb files with this command:
|
||||
```
|
||||
flutter pub run intl_translation:extract_to_arb --output-dir=lib/i18n lib/i18n/i18n.dart
|
||||
```
|
||||
|
||||
3. Copy the new translation objects from `/lib/i18n/intl_message.arb` to `/lib/i18n/intl_<yourlanguage>.arb` and translate it or create a new file for your language by copying `intl_message.arb`.
|
||||
|
||||
4. Update the translations with this command:
|
||||
```
|
||||
flutter pub run intl_translation:generate_from_arb \
|
||||
--output-dir=lib/i18n --no-use-deferred-loading \
|
||||
lib/main.dart lib/i18n/intl_*.arb
|
||||
```
|
||||
|
||||
5. Make sure your language is in `supportedLocales` in `/lib/main.dart`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue