question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fallbackLanguage broken after upgrade to 2.9

See original GitHub issue

Subject of the issue

After upgrading from angular 1.4 to 1.5 and angular-translate from 2.8 to 2.9, language switching to “fallbackLanguage” stopped working.

Your environment

  • version of angular-translate: 2.9.2
  • version of angular: 1.5.0
  • which browser and its version: Firefox, Chrome

Steps to reproduce

In our application, language switching stopped working in a strange way. Switching among all languages works, but we cannot switch to ‘en’. After some investigation, we found that dropping

$translateProvider.fallbackLanguage(‘en’);

fixes the switching problems. Here is a part of our code:

.config(function ($translateProvider) {
  $translateProvider.useLocalStorage();
  $translateProvider.useSanitizeValueStrategy('sanitizeParameters');
  $translateProvider.useMessageFormatInterpolation();
  $translateProvider.preferredLanguage('en');
  $translateProvider.fallbackLanguage('en');
  $translateProvider.uniformLanguageTag('bcp47');
  $translateProvider.determinePreferredLanguage();
  $translateProvider.registerAvailableLanguageKeys(['en', 'cs', 'pl'], {
    // en
    'en-AU': 'en', 'en-BZ': 'en', 'en-CA': 'en', 'en-CB': 'en', 'en-GB': 'en', 'en-IE': 'en', 'en-JM': 'en',
    'en-NZ': 'en', 'en-PH': 'en', 'en-TT': 'en', 'en-US': 'en', 'en-ZA': 'en', 'en-ZW': 'en',
    // cs
    'cs-CZ': 'cs',
    //pl
    'pl-PL': 'pl'
  });

  $translateProvider.useLoader('$translatePartialLoader', {
    urlTemplate: 'modules/{part}/{lang}.json',
    loadFailureHandler: 'SITranslationErrorHandler'
  });
  $translateProvider.useLoaderCache(true);
})

.run(function ($rootScope, $stateParams, $translate, $translatePartialLoader){
  $rootScope.$on('$stateChangeSuccess', function () {
    if ($stateParams.lang !== undefined){
      $rootScope.activeLang = $stateParams.lang;
      $translate.use($stateParams.lang);
      $translatePartialLoader.addPart('translation');
      $translate.refresh();
    }
  });
});

Another way how to fix switching (but without dropping fallback language) is to move fallback language to .run() block:

$translate.fallbackLanguage(‘en’);

and change useLocalStorage to useCookieStorage. Just one of these changes was not sufficient.

Expected behaviour

Language switching should be working - language should be switched.

Actual behaviour

Language switching is working except that switch to “fallbackLanguage” is ignored.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
knallicommented, Feb 28, 2016

Published 2.10.0 few minutes ago, including the PR by @tspaeth .

0reactions
sebek64commented, Feb 29, 2016

Confirming that 2.10.0 fixes the bug, thanks to all who worked on the solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Localization fallback language is incorrectly set due ... - GitHub
I am able to reproduce the issue on stable and the master channel. Changing the order of supported locales gets reset to alphabetic...
Read more >
Fallback Contract Language - Alternative Reference Rates ...
These consultations outline draft language to be voluntarily incorporated in new contracts that reference USD LIBOR to ensure these contracts will continue to ......
Read more >
ARRC Issues Updated Recommended Fallback Language for ...
After receiving market input on numerous occasions, it released its initial recommended Libor fallback language for bilateral business loans ...
Read more >
Upgrading from Craft 2 | Craft CMS Documentation | 3.x
The first step to upgrading your site to Craft 3 is updating the CMS itself. # Preparing for the Upgrade. Before you begin,...
Read more >
Booting and Shutting Down Oracle® Solaris 11.4 Systems
This procedure applies to those systems that have service processors (SPs) with the fallback miniroot installed. Whenever you update to an SRU version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found