-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fronted): add catalyst_voices_localization pub
- Loading branch information
Showing
18 changed files
with
374 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
catalyst_voices/packages/catalyst_voices_localization/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# VSCode related | ||
.vscode/* | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
pubspec.lock | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Test related | ||
coverage |
118 changes: 118 additions & 0 deletions
118
catalyst_voices/packages/catalyst_voices_localization/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Catalyst Voices Localization | ||
|
||
This package contains the localization files for the Catalyst Voices app. | ||
|
||
* [Catalyst Voices Localization](#catalyst-voices-localization) | ||
* [Working with Translations](#working-with-translations) | ||
* [Adding Strings](#adding-strings) | ||
* [Adding Supported Locales](#adding-supported-locales) | ||
* [Adding Translations](#adding-translations) | ||
|
||
## Working with Translations | ||
|
||
This project relies on [flutter_localizations](https://github.com/flutter/flutter/tree/master/packages/flutter_localizations). | ||
It follows the [official internationalization guide for Flutter][flutter-intl-guide]. | ||
|
||
### Adding Strings | ||
|
||
1. To add a new localizable string, open the `app_en.arb` file at `lib/l10n/arb/app_en.arb`. | ||
|
||
```arb | ||
{ | ||
"@@locale": "en", | ||
"counterAppBarTitle": "Counter", | ||
"@counterAppBarTitle": { | ||
"description": "Text shown in the AppBar of the Counter Page" | ||
} | ||
} | ||
``` | ||
|
||
2. Then add a new key/value and description | ||
|
||
```arb | ||
{ | ||
"@@locale": "en", | ||
"counterAppBarTitle": "Counter", | ||
"@counterAppBarTitle": { | ||
"description": "Text shown in the AppBar of the Counter Page" | ||
}, | ||
"helloWorld": "Hello World", | ||
"@helloWorld": { | ||
"description": "Hello World Text" | ||
} | ||
} | ||
``` | ||
|
||
3. Use the new string | ||
|
||
```dart | ||
import 'package:catalyst_voices/l10n/l10n.dart'; | ||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = context.l10n; | ||
return Text(l10n.helloWorld); | ||
} | ||
``` | ||
|
||
### Adding Supported Locales | ||
|
||
Update the `CFBundleLocalizations` array in the `Info.plist` at `ios/Runner/Info.plist` to include the new locale. | ||
|
||
```xml | ||
... | ||
|
||
<key>CFBundleLocalizations</key> | ||
<array> | ||
<string>en</string> | ||
<string>es</string> | ||
</array> | ||
|
||
... | ||
``` | ||
|
||
### Adding Translations | ||
|
||
1. For each supported locale, add a new ARB file in `lib/l10n/arb`. | ||
|
||
```tree | ||
├── l10n | ||
│ ├── arb | ||
│ │ ├── app_en.arb | ||
│ │ └── app_es.arb | ||
``` | ||
|
||
2. Add the translated strings to each `.arb` file: | ||
|
||
`app_en.arb` | ||
|
||
```arb | ||
{ | ||
"@@locale": "en", | ||
"counterAppBarTitle": "Counter", | ||
"@counterAppBarTitle": { | ||
"description": "Text shown in the AppBar of the Counter Page" | ||
} | ||
} | ||
``` | ||
|
||
<!-- cspell: words Contador Texto mostrado página --> | ||
|
||
`app_es.arb` | ||
|
||
```arb | ||
{ | ||
"@@locale": "es", | ||
"counterAppBarTitle": "Contador", | ||
"@counterAppBarTitle": { | ||
"description": "Texto mostrado en la AppBar de la página del contador" | ||
} | ||
} | ||
``` | ||
|
||
```shell | ||
flutter gen-l10n | ||
``` | ||
|
||
|
||
[flutter-intl-guide]: https://docs.flutter.dev/development/accessibility-and-localization/internationalization |
9 changes: 9 additions & 0 deletions
9
catalyst_voices/packages/catalyst_voices_localization/l10n.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
arb-dir: lib/l10n | ||
output-dir: lib/generated/ | ||
template-arb-file: intl_en.arb | ||
output-localization-file: catalyst_voices_localizations.dart | ||
output-class: VoicesLocalizations | ||
preferred-supported-locales: | ||
- en | ||
use-deferred-loading: true | ||
synthetic-package: false |
4 changes: 4 additions & 0 deletions
4
catalyst_voices/packages/catalyst_voices_localization/lib/catalyst_voices_localization.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// A Very Good Project created by Very Good CLI. | ||
library catalyst_voices_localization; | ||
|
||
export 'src/catalyst_voices_localization.dart'; |
Oops, something went wrong.