Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

translation fallback to preferred language #67

Closed
lanlau opened this issue May 29, 2013 · 3 comments
Closed

translation fallback to preferred language #67

lanlau opened this issue May 29, 2013 · 3 comments

Comments

@lanlau
Copy link
Contributor

lanlau commented May 29, 2013

Hi,
sometimes it occurs that a few translations are missing in one language but we have to wait to get them. I known that i can log those missing translations using the useMissingTranslationHandler but what i would like to do the following:
i've defined en-GB as my preferred language, the user changes the language to fr but in the translation table there are a few translationIDs missing, is it actually possible to load the en_GB translations only for those missing translationIDs ?

i've managed to do it (quite dirty i think...) by adding the following code right after your "var translation=..." in the provider

if(!translation && $uses && $uses!==$preferredLanguage){
            translation=$translationTable[$preferredLanguage][translationId];
}

would you have a better solution ?
thanks for all the work done is this fabulous module !

@0x-r4bbit
Copy link
Member

Hey @lanlau! I think this is a great feature we should provide. There was already the idea to have a fallback language, when I was presenting angular-translate at a local meetup.

Let's make a new feature of it! I think we should introduce something like

$translateProvider.fallbackLanguage(langKey)

So if you current workaround works for you, stick with it, until this feature is implemented. :) You could also speed up the process by providing a Pull Request by yourself (which is always awesome) :)

Is that okay for you?

@lanlau
Copy link
Contributor Author

lanlau commented May 29, 2013

great! i've tried to make a pull request, this is my first one ever....

@0x-r4bbit
Copy link
Member

So congrats to your first PR :) I'd love to get you in the OSS world by merging this one, I've commented a few lines of code on the commit. Check the PR for mor information.

Thanks for your work! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants