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

determinePreferredLanguage() + registerAvailableLanguageKeys() still try to load unavailable language #1390

Closed
PaulAnnekov opened this issue Feb 3, 2016 · 4 comments

Comments

@PaulAnnekov
Copy link

When using determinePreferredLanguage() function to automatically detect language based on Navigator and registerAvailableLanguageKeys() to set available languages list, if unavailable language detected, then angular translate still tries to load it using translation loader. Why does it do this? It's unavailable.
POC: plunker

@knalli knalli added the bug label Feb 9, 2016
@knalli knalli added this to the 2.9.1 milestone Feb 9, 2016
@knalli
Copy link
Member

knalli commented Feb 9, 2016

Yeah, this sounds valid.

We have to revisit

if (parts.length > 1 && indexOf(avail, angular.lowercase(parts[0])) > -1) {
return parts[0];
}

@knalli knalli modified the milestones: 2.11.0, 2.10.0 Feb 28, 2016
@tspaeth
Copy link
Member

tspaeth commented Mar 1, 2016

Question - Implementation should be:

No matter, what determinePreferredLanguage analyzed - the registerAvailableLanguageKeys - output defines the valid languages.
Therefore if your browser is de-DE and this is the preferred due to this - which of the languages shall be chosen as the active one by the module?

Usually, you could now define this wildcard mapping as a second parameter (maybe needing the correct mappings in before - didn'T test it:

registerAvailableLanguageKeys(languages, {
      "*": "ar"
    })

@knalli
Copy link
Member

knalli commented Mar 6, 2016

Therefore if your browser is de-DE and this is the preferred due to this - which of the languages shall be chosen as the active one by the module?

The fallback one.

Perhaps we should log a warning if the combo preferredLanguage + available + fallback will result into nothing..

knalli added a commit that referenced this issue Mar 20, 2016
…nted

Although (valid) available language keys have been registered with `registerAvailableLanguageKeys()`, the service tried to load non matching languages.

Fixes #1390
@knalli
Copy link
Member

knalli commented Mar 20, 2016

Fixed with bde935e -- with test case.

@knalli knalli closed this as completed Mar 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants