-
Notifications
You must be signed in to change notification settings - Fork 274
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
Accept-Language de-DE
does not end up using de.all.json
#76
Comments
I come from a Java world so I was surprised by this as well. In Java if you had the files: en.all.json Then en and en_US etc. would both match to that file whereas if you just had: en_US.all.json Then en would not match it but en_US would so the opposite of the matching rules here. I can see some merit of matching to more specific languages (i.e. en -> en_US, although I'm not convinced this will work for all languages) but think that the opposite should also be supported... |
I just read through the very informative and interesting: https://blog.golang.org/matchlang Looking at what the |
I agree that it would be ideal for this project to depend on
There is probably some low hanging fruit as you describe (which was mentioned in #30) for making the current matching slightly better. I am open to PRs for this. Right now I don't have time to allocate to this. |
Also related: #44 |
v2 contains a proposal to fix this. See #92 |
More specifically, it relies go golang.org/x/text/language |
I just tagged 2.0.0.beta.1. Please start using it and report any issues that you have. |
Hi!
This might be similar to #30 but that issue is quite old so I'm rather starting a new one here. I'm not sure it's completely related.
My setup
I am using simply
de
anden
because there is just one translation for each language, no flavours and I want them to be used for any kind of locales of those languages that come along, be iten-GB
,en-US
,de-CH
,de-DE
, etc. Default language isen
in any case, and I really want to get the English text if the German version should not be found for some reason (which best should never happen).The issue
With Accept-Language header
de-DE
, thede
translations are not found.This is because
lang.MatchingTags()
is only applied when adding translations (so in my casede
,en
, and of course the matching tags are onlyde
anden
).When the translation function is requested for
de-DE
, onlylang.Tag
is used to lookup the fallback language and this is then onlyde-de
(inbundle.translatedLanguage()
).So, my question is, would it not make more sense to use
lang.MatchingTags()
also inbundle.translatedLanguage()
where the fallback is looked up?The text was updated successfully, but these errors were encountered: