-
Notifications
You must be signed in to change notification settings - Fork 277
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
Preferences don't cascade on translation #30
Comments
I have a couple thoughts:
Basically each locale should contain a full copy of all translations, even if some translations are the same across multiple sublocales. |
@parkr thoughts? |
Hey Nick, sorry for my delayed reply. You gave me some good stuff to think over and I had to write some
I agree it would not be an obvious move here. I'm not thinking one part of one page would be in English with scattered Thai or German depending upon what's available. I mean entire resources could move independently. I could have one tfunc generated, and generate a series of different emails, say. The first email has no Thai translation, so the user gets English. The second email does have a translation, so it gets the Thai translation. This is the reality of incrementally shipping translations. We want a first iteration out quickly – do it in English, get our Copy team to sign off on it and ship it. Submit it to your translation vendor and as accurate, verified translations come in, add them, but always fall back to English (our "master" version) in case the more preferred languages don't have translations. The trade-off here is that we fall back to our least-preferred language instead of an empty string. In my view, the user should get at least something.
I think this is a fair and reasonable assumption for most teams. I can't imagine what you'd translate if you didn't have it in some language. Usually you write in the company's native tongue and you translate from there. Seems very reasonable to me to assume this.
If a translation is missing from one locale, you get an unhelpful error state at the moment anyway: an empty string. If you at least get some copy, even if it's in English, you're better off. It'd be mighty difficult to catch an empty string, but you'll notice the random English sentence in a sea of Russian, German, Dutch, French, or Thai (etc). I think falling back to the master language is more useful than providing
This creates a huge copy pasta problem. I have one translation for English here and I tweak it a tiny bit in my master |
Any further thoughts on my thoughts? |
That is a reasonable thing to want to do, so perhaps we need to add a way to opt in to this fallback behavior. I don't think it should be the default behavior though, because another reasonable thing to do is not send the email at all until you have a translation for it. To do this, Tfunc needs to return something that allows the caller to detect a translation is missing, so that is why Tfunc should return the translation id.
Tfunc should return the translation id or non-empty string (which is presumably a translation). If you are observing otherwise, it is a bug which I would like to fix. Looking at the code, I don't see how it could return the empty string ""
I don't quite understand the problem; why would a developer want to edit th-TH.json? The workflow that I have in mind is:
Is your workflow different than this? |
The behaviour described here is basically what Java does: |
Can keep this open. It is something that I am thinking about for v2 |
v2 includes logic to do this fallback according to CLDR rules (by importing and using golang.org/x/text/language) See #92 |
I just tagged 2.0.0.beta.1. Please start using it and report any issues that you have. |
Hey, @nicksnyder! Ran into an issue today you might find interesting. Here's my situation.
I have three files, all for English:
en.all.json
,en-US.all.json
, anden-GB.all.json
. The first holds all English translations that are common between all variations of English we support. The second and third files hold translations specific to their respective locales.A user requests something from us, and sends us the locale
en-US
. We make aTranslationFunc
with preferencesen-US, en
. Now here's where we run into a problem: if I ask for a translation that is not inen-US.all.json
, it returns thetranslationID
instead of looking insideen.all.json
for a relevant translation.This is due to the way
bundle.TfuncAndLanguage
handles language preferences. When I ask foren-US
and the language has any translations, it limits the search to this map, ignoring the remaining language preferences.I'd like to support the preference fallback at the translation level, instead of the language level. In pseudocode, this is:
What do you think?
The text was updated successfully, but these errors were encountered: