You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
The fallback language is not working when useLocalStorage() is being used. That is the fallback language does work if one uses the filter, but not when using the directive or the $translate service directly.
This is how I set up the translations in my app.js:
angular.module('myApp', [
'ngRoute',
'pascalprecht.translate',
'ngCookies',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', '$translateProvider', function($routeProvider, $translateProvider) {
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
$routeProvider.otherwise({redirectTo: '/view1'});
$translateProvider
.translations('en', {
'TEXT1': 'EN TEXT1',
'TEXT2': 'EN TEXT2'
})
.translations('de', {
'TEXT1': 'DE TEXT1'
})
.fallbackLanguage('en')
.useLocalStorage() // If you comment this out everything works as expected
.preferredLanguage('de')
;
}]);
Expected result is that for TEXT1 the German translation is used, but for TEXT2 it will fallback to the English translation. But the actual result is
<p>This is the partial for view 1.</p>
<h1>Display TEXT1 (should use requested language DE)</h1>
<div>{{ 'TEXT1' | translate }}</div> <!-- Ok, shows 'DE TEXT1' -->
<div translate="TEXT1"></div> <!-- Ok, shows 'DE TEXT1' -->
<h1>Display TEXT2 (should use fallback language EN)</h1>
<div>{{ 'TEXT2' | translate }}</div> <!-- Ok, shows 'DE TEXT2' -->
<div translate="TEXT2"></div> <!-- Shows the string identifier instead of the fallback -->
Using $translate in a controller will behave just like the translatedirective and will not show the fallback for TEXT2. If you disable the local storage the fallback works reliable.
The text was updated successfully, but these errors were encountered:
The fallback language is not working when
useLocalStorage()
is being used. That is the fallback language does work if one uses the filter, but not when using the directive or the $translate service directly.This is how I set up the translations in my app.js:
Expected result is that for TEXT1 the German translation is used, but for TEXT2 it will fallback to the English translation. But the actual result is
Using
$translate
in a controller will behave just like thetranslate
directive and will not show the fallback for TEXT2. If you disable the local storage the fallback works reliable.The text was updated successfully, but these errors were encountered: