-
Notifications
You must be signed in to change notification settings - Fork 1k
$translateProvider.determineLanguage does not work on Safari as expected #431
Comments
Exactly, 'en_US' and 'en_us' are two different keys for angular-translate. Mind sending a PR? :) |
…y aliases When language key aliases are available they are now compared to the browsers locale in a case-insensitive manner. Closes Issue angular-translate#431
When language key aliases are available they are now compared to the browsers locale in a case-insensitive manner. Closes Issue angular-translate#431
When language key aliases are available they are now compared to the browsers locale in a case-insensitive manner. Closes Issue #431
@PascalPrecht Can we close this one though? |
I still have this issue in both version angular
.module('myApp', ['pascalprecht.translate'])
.config(function($provide) {
$provide.decorator('$translate', function($delegate) {
var _preferredLanguage = $delegate.preferredLanguage;
$delegate.preferredLanguage = function() {
var guessed = _preferredLanguage();
// ensure that $preferredLanguage looks like fr_FR or fr_fr [Safari], and not "fr-fr" of just "fr", ...
var language = guessed.match(/^[a-z]{2}([-_][a-zA-Z]{2})?$/);
if (language !== null && language[0] === guessed) {
var splittedLanguages = language[0].replace('-', '_').split('_');
if (splittedLanguages.length === 1) {
// fr => fr_FR
return splittedLanguages[0].toLowerCase() + '_' + splittedLanguages[0].toUpperCase();
} else if (splittedLanguages.length === 2) {
// fr_fr => fr_FR
return splittedLanguages[0].toLowerCase() + '_' + splittedLanguages[1].toUpperCase();
}
}
return guessed;
};
return $delegate;
});
}) By doing so, I thought that resolution of #722 in
|
Maybe you send this as a PR? :) |
With pleasure! But if I propose this as a PR, I'm going to directly include it in the code, not as a decorator. I think |
Of course :) I would prefer either |
Closing this, we have the open PR (#755). That is still valid. |
The PR was replaced with a feature named uniformLanguageTag. Preview available here. |
When I use
$translateProvider.determineLanguage
in combination with$translateProvider.registerAvailableLanguageKeys
, I would expect that the language keyen_US
would match case-insensitive, but it doesn't.The following plunker shows that bug. On Safari, no matching language key is found and you see no translation. On Chrome it works as expected.
http://plnkr.co/edit/gFzzNh?p=preview
The text was updated successfully, but these errors were encountered: