-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support properties on (linked) translations #275
Comments
Thanks for the pull request! At first glance, this feature is quite complex.
The given example implies, that you can have multiple properties of the same type. In general, I would advice you to use the enums feature (https://pub.dev/packages/slang#-custom-contexts--enums) to implement this logic. For example: workType(context=I18nWorkType):
task: "Aufgabe"
order: "Auftrag"
general: "" # not used in German
noTasks(context=I18nWorkType):
task: "Diese @:workType hat keine Positionen."
order: "Dieser @:workType hat keine Positionen."
general: "" # not used in German I18nWorkType workType = I18nWorkType.order;
print(t.noTasks(context: workType)); // prints "Dieser Auftrag hat keine Positionen.
workType = I18nWorkType.task;
print(t.noTasks(context: workType)); // prints "Diese Aufgabe hat keine Positionen." The downside is that you move i18n logic into business logic space. However, I think that The reason, I am hesitant is because this feature adds complexity of a novel feature that I've not seen in other i18n libraries. |
Thanks for the response! I could indeed solve this problem with enums, at the price of having the article passed in through an enum on every translation that uses If we can agree that this is a legitimate use case, then I do think this is at least worth exploring.
I imagined it as more of a bottom-up enum, where instead of values being passed down from the translation consumer, they are passed up from translation values and other translations may be the consumer. In that sense I didn't imagine
I suppose that could also work. |
Motivation
Hello!
In our project we use certain domain words that need to be able to be swapped out; for example
domain.workOrder
here:I can use linked translations to reuse these and
LocaleSettings.overrideTranslationsFromMap
to swap them out as needed, so far so good, love that.But then I add German translations and now the parent translation depends on the linked translation's grammatical gender:
I would like to have the possibility to adapt the parent (
noTasks
) translation based on a property of the linked (domain.workOrder
) value. I think that would solve this problem in a fairly elegant way and probably enable some other use cases that I didn't think of (yet). I sketched out a rough draft of what this could look like below.Is this something that we could add? I would be willing to implement this, if it helps 🙂
Developer Experience
An example of what this feature could look like:
Importantly, this needs to be locale-specific. In English, the above would look like this:
But I imagine there might be a use-case for non-locale-specific properties as well? Those could be listed under something like
properties.global
if need be.The text was updated successfully, but these errors were encountered: