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

Case in available language keys is handled inconsistantly. #1788

Closed
jjabba opened this issue Sep 28, 2017 · 3 comments
Closed

Case in available language keys is handled inconsistantly. #1788

jjabba opened this issue Sep 28, 2017 · 3 comments
Milestone

Comments

@jjabba
Copy link

jjabba commented Sep 28, 2017

Letter case in available language keys is sometimes ignored, behaviour is inconsistant.

When registering 'avaliable languages' such as (en_UK, de_DE) the letter case of the language returned when language is negotiated is inconsistant. It's sometimes en_UK, sometimes en_uk, depending on the way a match is found.

Your environment

  • angular-translate - v2.15.2 - 2017-06-22
  • AngularJS v1.6.6
  • all browsers/environments

Steps to reproduce

Run the testcase supplied in pull request #1783 or look at this plunker https://plnkr.co/edit/5Eu5Qu0EXlBGd0ecigPg?p=preview

Expected behaviour

The language returned from $translate.use() should respect casing used when registering avaliable languages.

Actual behaviour

Depending on how matching is done in internal function 'negotiateLocale(preferred)', sometimes the letter case is respected, but sometimes not.

Fix

I've implemented a solution in pull request #1784 which passes the test in pull request #1783 and makes the returned language always respect case used when registering avaliable languages.

Why?!

The importance for this fix is more obvious if ngTranslate is used with the angular-translate-loader-static-files loader. Since the key/identifyer/language resolved by negotiateLocale() is used to determine which fileUrl is loaded, loading translations will fail if the server hosting the translations is case sensitive. This was how I originally found this bug.

@knalli
Copy link
Member

knalli commented Sep 28, 2017

@jjabba Thank you for all the great PRs! 🏎

I will have a look asap.

@jjabba
Copy link
Author

jjabba commented Sep 28, 2017

@knalli Thanks for an awesome module, glad to try and make it even more awesome, my product is dependent on it.

knalli pushed a commit that referenced this issue Oct 3, 2017
If a language matches an available language using lowercase comparison, the available language will be returned with case intact.

Relates #1788
knalli pushed a commit that referenced this issue Oct 3, 2017
Test expects the available language string to be used even though comparison is case insensitive.

Relates #1788
@knalli knalli added this to the 2.16.0 milestone Oct 3, 2017
@knalli
Copy link
Member

knalli commented Oct 3, 2017

Thank you very much for these contributions. Same as in #1789 :)

@knalli knalli closed this as completed Oct 3, 2017
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