Skip to content
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

Fallback improvement #210

Closed
knuhol opened this issue Aug 10, 2015 · 15 comments · May be fixed by #345
Closed

Fallback improvement #210

knuhol opened this issue Aug 10, 2015 · 15 comments · May be fixed by #345

Comments

@knuhol
Copy link

knuhol commented Aug 10, 2015

It would be nice to have improved fallback langugage. E.g. I have the string in the locale de but I don't have the string in the locale de_CH. Actually, if the user uses locale de_CH, the string in the default langugae (= English) is used but it is better for user to use the string of locale de instead. Then, if no string for locale de_CH either for locale de exists, the English string is used.

Is it possible? It would be nice to have also a possibility to define this 'fallback waterfall' but the default gettext behaviour is enough I think: (country specific locale, e.g. 'de_CH') -> (general locale, e.g. 'de') -> (the default language = English).

@rubenv
Copy link
Owner

rubenv commented Aug 10, 2015

Yes, we should have this. Never got round to adding it.

Same logic should apply for resolving plural rules.

@innerpeace0
Copy link

+1. Thank you.

@rubenv
Copy link
Owner

rubenv commented Aug 10, 2015

Anyone want to have a go at fixing this?

@knuhol
Copy link
Author

knuhol commented Sep 9, 2015

Any news about this?

@crissdev
Copy link
Contributor

I see @jpzwarte has some implementation in his fork but haven't tested it.

@rubenv
Copy link
Owner

rubenv commented Sep 23, 2015

Given that language codes are standardised, it's probably not needed to expose it as an option. The fallback language can be derived automatically: e.g.: nl_BE -> nl.

@crissdev
Copy link
Contributor

@rubenv That's correct but I think there'll still be needed for a general fallback language and use it only if it was defined by the user. Otherwise just use the detected fallback.
To sum, with what @Akarienta said, de_DE 👉 de 👉 fallbackLanguage

@rubenv
Copy link
Owner

rubenv commented Sep 23, 2015

@crissdev I'm not following you there. Is fallbackLanguage something configurable? As opposed to the current behaviour, where we use the (English) source string?

@knuhol
Copy link
Author

knuhol commented Sep 23, 2015

Given that language codes are standardised, it's probably not needed to expose it as an option.

Half a truth. There are also some languages which are very similar. E.g. if my mother lang is sk I would prefer lang cs in the app rather then en because I understand it natively without any problem (not the case of English).

@crissdev
Copy link
Contributor

I can see what I forgot to add.

de_DE 👉 de 👉 fallbackLanguage 👉 (English source string)

@knuhol
Copy link
Author

knuhol commented Sep 23, 2015

@crissdev This solution would be realy nice.

@rubenv
Copy link
Owner

rubenv commented Sep 23, 2015

@crissdev @Akarienta That will only work if plural rules are equal for those languages (which we can expect for variants of the same base language).

I'd rather not support this, for two reasons:

  • The goal for angular-gettext is to keep things as simple as possible. A fallback language as described above is a complex corner case not supported by other gettext implementations.
  • Missing strings should be the exception, rather than the rule. If not having English anywhere in your app is crucial: don't ship before you update your translations.

@jpzwarte
Copy link

@rubenv only automatic fallback by doing nl_NL -> nl is insufficient for our needs. We have specific POs which are content related, not only language related. So being able to specify the actual PO used as a fallback is a requirement for us.

@knuhol
Copy link
Author

knuhol commented Sep 23, 2015

@rubenv Well that's right, obviously. In fact, a user can change the language in app settings in case I am writing about (if he/she likes).

This solution would be enough then: de_DE 👉 de 👉 (English source string).

@crissdev
Copy link
Contributor

Having the fallback as above would be fine (and enough) as well.

crissdev added a commit to crissdev/angular-gettext that referenced this issue Oct 27, 2015
crissdev added a commit to crissdev/angular-gettext that referenced this issue Oct 27, 2015
@rubenv rubenv closed this as completed in dfa89d0 Dec 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants