-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add easy localization package to project #38
- add en/es/fr.json translation files - generate codegen_loader.g & locale_keys.g files - update pubspec.yaml file - update text variables - add `build_runner.sh` file - update `app theme data` - update test files
- Loading branch information
1 parent
f551393
commit 4ee1611
Showing
17 changed files
with
160 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"title": "Hello, World!", | ||
"subtitle": "Welcome to Localization", | ||
"description": "You have pushed the button this many times:", | ||
"switchLanguage": "Switch language" | ||
} |
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,6 @@ | ||
{ | ||
"title": "¡Hola, Mundo!", | ||
"subtitle": "Bienvenido a Localización", | ||
"description": "Has pulsado el botón tantas veces:", | ||
"switchLanguage": "Cambiar idioma" | ||
} |
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,6 @@ | ||
{ | ||
"title": "Bonjour", | ||
"subtitle": "Bienvenue dans Localisation", | ||
"description": "Vous avez appuyé sur le bouton autant de fois :", | ||
"switchLanguage": "Changer de langue" | ||
} |
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,62 @@ | ||
#!/bin/bash | ||
|
||
# Welcome message | ||
echo "Welcome to the Build Runner Wizard!" | ||
|
||
# Display options to the user | ||
echo "Please select an option:" | ||
echo "1. Automatic Execution" | ||
echo "2. Manual Execution" | ||
echo "3. Re-Build Translation Files" | ||
echo "4. Re-Generate Asset Files" | ||
|
||
# Read user input | ||
read -p "Enter your choice (1, 2, 3, or 4): " choice | ||
|
||
# Check selected option and execute corresponding commands | ||
case $choice in | ||
1) | ||
echo "* You selected Automatic Execution." | ||
# Automatic execution | ||
|
||
# Rebuild translation files | ||
dart run easy_localization:generate --source-dir=assets/translations --output-dir=lib/src/core/utils/gen/localization | ||
dart run easy_localization:generate -f keys -o locale_keys.g.dart --source-dir=assets/translations --output-dir=lib/src/core/utils/gen/localization | ||
dart run build_runner build --delete-conflicting-outputs --build-filter="lib\src\core\constants\localization\*.dart" | ||
|
||
# Execute automatic build runner command | ||
dart run build_runner build --delete-conflicting-outputs | ||
;; | ||
2) | ||
echo "* You selected Manual Execution." | ||
# Read user input text | ||
read -p "Enter your text (comma-separated list for multiple items): " text | ||
|
||
# Convert input text to an array using ',' as a delimiter | ||
IFS=',' read -r -a text_array <<< "$text" | ||
|
||
# Loop through each item in the array and execute the command | ||
for item in "${text_array[@]}" | ||
do | ||
# Replace '/' with '\' in the input text | ||
text_with_backslashes=$(echo "$item" | sed 's/\//\\/g') | ||
# Replace the desired text in the command and execute it | ||
dart run build_runner build --delete-conflicting-outputs --build-filter="$text_with_backslashes\*.dart" | ||
done | ||
;; | ||
3) | ||
echo "* You selected Re-Build Translation Files." | ||
# Execute commands for rebuilding translation files | ||
dart run easy_localization:generate --source-dir=assets/translations --output-dir=lib/src/core/utils/gen/localization | ||
dart run easy_localization:generate -f keys -o locale_keys.g.dart --source-dir=assets/translations --output-dir=lib/src/core/utils/gen/localization | ||
dart run build_runner build --delete-conflicting-outputs --build-filter="lib\src\core\constants\localization\*.dart" | ||
;; | ||
4) | ||
echo "* You selected Re-Generate Asset Files." | ||
# Execute commands for rebuilding asset files | ||
dart run build_runner build --delete-conflicting-outputs --build-filter="lib\src\core\utils\gen\assets\*.dart" | ||
;; | ||
*) | ||
echo "* Invalid choice. Please enter 1, 2, 3, or 4." | ||
;; | ||
esac |
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 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 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
17 changes: 17 additions & 0 deletions
17
lib/src/core/utils/assets/assets.gen.dart → ...src/core/utils/gen/assets/assets.gen.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
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,37 @@ | ||
// DO NOT EDIT. This is code generated via package:easy_localization/generate.dart | ||
|
||
// ignore_for_file: prefer_single_quotes, avoid_renaming_method_parameters | ||
|
||
import 'dart:ui'; | ||
|
||
import 'package:easy_localization/easy_localization.dart' show AssetLoader; | ||
|
||
class CodegenLoader extends AssetLoader{ | ||
const CodegenLoader(); | ||
|
||
@override | ||
Future<Map<String, dynamic>?> load(String path, Locale locale) { | ||
return Future.value(mapLocales[locale.toString()]); | ||
} | ||
|
||
static const Map<String,dynamic> en = { | ||
"title": "Hello, World!", | ||
"subtitle": "Welcome to Localization", | ||
"description": "You have pushed the button this many times:", | ||
"switchLanguage": "Switch language", | ||
}; | ||
static const Map<String,dynamic> es = { | ||
"title": "¡Hola, Mundo!", | ||
"subtitle": "Bienvenido a Localización", | ||
"description": "Has pulsado el botón tantas veces:", | ||
"switchLanguage": "Cambiar idioma", | ||
}; | ||
static const Map<String,dynamic> fr = { | ||
"title": "Bonjour", | ||
"subtitle": "Bienvenue dans Localisation", | ||
"description": "Vous avez appuyé sur le bouton autant de fois :", | ||
"switchLanguage": "Changer de langue", | ||
}; | ||
static const Map<String, Map<String,dynamic>> mapLocales = {"en": en, "es": es, | ||
"fr": fr,}; | ||
} |
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 @@ | ||
// DO NOT EDIT. This is code generated via package:easy_localization/generate.dart | ||
|
||
abstract class LocaleKeys { | ||
static const title = 'title'; | ||
static const subtitle = 'subtitle'; | ||
static const description = 'description'; | ||
static const switchLanguage = 'switchLanguage'; | ||
|
||
} |
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 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 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 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 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 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