Code Monkey home page Code Monkey logo

Comments (3)

theSoenke avatar theSoenke commented on August 20, 2024 2

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.

mugbug avatar mugbug commented on August 20, 2024 1

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.

theSoenke avatar theSoenke commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.