-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse existing translation #12
Comments
I can resolve by writing this:
but it doesn't resolve for cases that the reusable translations has parameters, for example:
that should output: and it doesn't resolve for cases that the reusable translations is a nested variable, for example:
|
@labibramadhan when using i18n on an app, it's a good idea to use full strings as messages. Building up messages from other small messages has 2 main disadvantages:
That said, your idea of nesting translations is an interesting one, but as you've discovered, translations don't compose very well. A translation is not just the original message, it's the message plus substitutions (variables). So to compose two messages into a new one, you need the new message and possible variables from any sub-messages:
Since the messages are translated at run-time you need to localise the messages multiple times to "get to the bottom" of the translation nesting:
Also, since languages will reuse messages in different ways, you don't even really know which variables you will need, so you then either need to manually inspect the message nesting, or make all possible variables available. If instead of reusing translations, you just want to include translated messages in other message, you can translate the message and provide it manually as a substitution:
This is basically the same as my recursion example above, but you're doing it by hand instead of the library doing it for you. |
Can i reuse existring translation? For example something like this:
The text was updated successfully, but these errors were encountered: