-
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.
Merge pull request #60 from pactus-project/feat/l10n-centralize-trans…
…lation-keys refactor: use `l10n` for localization and centralize translation keys
- Loading branch information
Showing
34 changed files
with
1,061 additions
and
426 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Welcome message | ||
# Displaying a welcome message to the user | ||
echo "Welcome to the Build Runner Wizard!" | ||
|
||
# Display options to the user | ||
# Showing the available 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" | ||
echo "2. Re-Generate Asset Files" | ||
|
||
# Read user input | ||
read -p "Enter your choice (1, 2, 3, or 4): " choice | ||
# Reading the user's input for their choice | ||
read -p "Enter your choice (1 or 2): " choice | ||
|
||
# Check selected option and execute corresponding commands | ||
# Handling the user's choice with a case statement | ||
case $choice in | ||
1) | ||
# User selected Automatic Execution | ||
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" | ||
# Step 1: Rebuilding translation files using the l10n package | ||
# This command generates localization files from ARB files located in assets/translations. | ||
flutter gen-l10n --output-dir=lib/l10n --arb-dir=lib/l10n | ||
|
||
# Execute automatic build runner command | ||
# Step 2: Running custom translation utilities | ||
# Executes the custom logic defined in translations_utils.dart (used for post-processing translations if needed). | ||
echo "* Running custom translations utilities from lib/src/core/utils/gen/localization/translations_utils.dart" | ||
dart lib/src/core/utils/gen/localization/translations_utils.dart | ||
|
||
# Step 3: Running build_runner to generate code for localization and other assets | ||
# This builds the project and deletes any conflicting outputs that may cause issues. | ||
dart run build_runner build --delete-conflicting-outputs | ||
|
||
# Step 4: flutter pub get for update l10n dependency | ||
flutter pub get | ||
;; | ||
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) | ||
# User selected Re-Generate Asset Files | ||
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" | ||
|
||
# Re-running build_runner to regenerate asset files | ||
# This specifically handles assets located in the 'assets' folder. | ||
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." | ||
# Invalid choice entered by the user | ||
echo "* Invalid choice. Please enter 1 or 2" | ||
;; | ||
esac | ||
|
||
# Pausing for 3 seconds before exiting to give the user a chance to read the output | ||
sleep 3s ; |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"title": "Hello, World!", | ||
"@@locale": "en", | ||
"title": "Hello, World !", | ||
"subtitle": "Welcome to Localization", | ||
"description": "You have pushed the button this many times:", | ||
"switch_language": "Switch language", | ||
"applications": "Applications" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"title": "¡Hola, Mundo!", | ||
"@@locale": "es", | ||
"title": "¡Hola, Mundo !", | ||
"subtitle": "Bienvenido a Localización", | ||
"description": "Has pulsado el botón tantas veces:", | ||
"switchLanguage": "Cambiar idioma", | ||
"switch_language": "Cambiar idioma", | ||
"applications": "Applications" | ||
|
||
} |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"title": "Bonjour", | ||
"@@locale": "fr", | ||
"title": "Bonjour le monde !", | ||
"subtitle": "Bienvenue dans Localisation", | ||
"description": "Vous avez appuyé sur le bouton autant de fois :", | ||
"switchLanguage": "Changer de langue", | ||
"switch_language": "Changer de langue", | ||
"applications": "Applications" | ||
} |
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
Oops, something went wrong.