Comments (3)
Hi @mugbug, thanks for sharing a workaround 🎉 With the latest release 2.4.0 output-class is now also supported directly by the SDK
from flutter_sdk_example.
Btw I was able to solve this by adding a script after the PhraseLocalizations
class was generated. Here it is in case anyone needs it:
#!/bin/bash
## This script is used to replace the value of 'output-class' field in the l10n.yaml file
##
## Note: this script should be called only through the `melos exec` command
## https://melos.invertase.dev/environment-variables#melos_package_path
package_path=$MELOS_PACKAGE_PATH
# Read the value of 'output-class' field from the l10n.yaml file
output_class=$(awk '/output-class/ {print $2}' $package_path/l10n.yaml)
# Replace occurrences of 'AppLocalizations' with the value of 'output-class' in the Dart file
sed -i '' "s/AppLocalizations/$output_class/g" $package_path/lib/src/l10n/generated/phrase_localizations.dart
echo "Replaced 'AppLocalizations' to '${output_class}'"
phrase_class="Phrase$output_class"
# Replace occurrences of 'PhraseLocalizations' with the value of 'Phrase + output-class' in the Dart file
sed -i '' "s/PhraseLocalizations/$phrase_class/g" $package_path/lib/src/l10n/generated/phrase_localizations.dart
echo "Replaced 'PhraseLocalizations' to '${phrase_class}'"
In my case I use melos to manage the packages, but it can be used with other tools just by changing the package_path=$MELOS_PACKAGE_PATH
to something like package_path=$1
and get the package path as a parameter when calling the script.
from flutter_sdk_example.
Hi @mugbug, I agree that it would be really useful to support setups like these for larger applications. When pulling the translations from Phrase how do you currently split it into multiple files for each package (ignoring the Phrase Flutter SDK for now)? Do you use tags or multiple projects?
Supporting this use case likely will require some larger changes in the architecture of over-the-air translations though. I'm creating a feature request for this to take a closer look at this
from flutter_sdk_example.
Related Issues (13)
- Placeholders not generated in .arb files for plural forms HOT 6
- Phrase.getText() not work. HOT 2
- Update of the dependencies HOT 2
- failed to run because of flutter_gen HOT 15
- chore(deps): please update `package_info_plus` constraints HOT 2
- bug: `Error: The class 'FileSystemEvent' can't be extended [...] in outside of its library because it's a sealed class.` HOT 1
- Phrase flutter HOT 1
- Feature request (Flutter): Deleting the cache on the local device HOT 3
- Feature Request : Translating a String variable HOT 4
- Problem with generating builds HOT 7
- Unit Testing HOT 6
- Modified generated code HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_sdk_example.