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.

Change language with $translatePartialLoader

See original GitHub issue

Hello,

i have a problem with loading the translations. I am using the $translatePartialLoader.

My versions: angular-translate - v2.15.2 - 2017-06-22 AngularJS v1.6.4 Google Chrome v59.0.3071.115

My problem: I am on state “profile” and have the active language “DE” now i am switching to language “EN”. Then i switch the state to “settings” and switch my language back to “DE”. Now i don’t see the my translations i only see my keys for the translations.

State change event

$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState) {
    $scope.unloadModule(event, fromState.name);
    $scope.loadModule(event, toState.name);
    $translate.refresh();
});

Functions for load/unload the modules

$scope.loadModule = function ($event, module) {
    $event.preventDefault();
    $translatePartialLoader.addPart(module);
};
$scope.unloadModule = function ($event, module) {
    $event.preventDefault();
    $translatePartialLoader.deletePart(module);
};

Thanks for watching for a solution.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
knallicommented, Jul 28, 2017

I think this should work

$translate.use(sprache)
  .then(function() {
    $translate.refresh();
  });

I’m not sure, looks like this is a specific issue with partial loading and language changes at all. Alternatively, don’t remove already loaded parts (depends on the number of translations).

0reactions
vicarycommented, Nov 8, 2018

@knalli Your workaround did the trick but still FOUC, should really resolve inside the library before it renders out any content IMO.

Not sure if I should open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PartialLoader: $translate.use() and $translate.refresh() in race ...
Set up a project using the partialLoader having at least two languages (f.e. English and German). Set English as fallback language; Call $ ......
Read more >
AngularJS : Setting languages in angular-translate from ...
First inject $translate into your controller. app.controller('MainCtrl', function($scope, $state, $translate) {});.
Read more >
Adding translation using angular-translate to an angularjs app
Go to common/translation/translation.js , and change the default language to fr-FR. You should get a translated teams page.
Read more >
Plato - service/loader-partial.js - Angular Translate
changed somehow. It could mean either some part is added or some part is deleted. Anyway when. 317. * you get this event...
Read more >
Angular Language Translations (i18n) using ngx ... - YouTube
Your browser can't play this video. Learn more. Switch camera.
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