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.

$translatePartialLoader.addPart causing multiple loads of each part

See original GitHub issue

I have a load of child modules within the app, each of which has its own translation bundle. when the module is loaded, it loads its translation bundle.

The problem i has is that when i load more than one module at a time, each module calls add part, the $translate.refresh call, loads the bundles more than once.

Example code (somewhat simplified!):

$rootScope.$on('$translatePartialLoaderStructureChanged',function () {
    $translate.refresh();
});

to add the parts:

function loadModule(module){
  $ocLazyLoad.load(module).then(function(){
    $translatePartialLoader.addPart(module);
  });
}
var modules = ['m1','m2','m3'];
angular.forEach(modules, function(module){
    loadModule(module);
});

The pattern of loads is:

m1,m1,m2,m1,m2,m3

It looks like the subsequent refreshes, aren’t aware that the module file has already been requested, so requests it again.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
weldelmongicommented, Jan 10, 2017

pour résoudre ce problème il faut lors de la config du module d’ajouter cette ligne $translateProvider.useLoaderCache(true);

0reactions
knallicommented, Feb 6, 2020

@dmitry-dedukhin I would imagine $http was not part of AngularJS at this time, but this is speculating. Also I’m not sure how it will deal with refreshing content.

So: Yes, you would build it with other existing tooling nowadays probably. But this is old cold base…

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-translate-loader-partial not loading {parts} outside of ...
If I try to use $translatePartialLoader.addPart(resource) on the initial load in a resource service, the "part" being loaded won't translate ...
Read more >
jhipster/generator-jhipster - Gitter
When I remove this line: $translatePartialLoader.addPart(''); Everything works well. This would be expected behavior or is it a bug?
Read more >
Internationalize Your AngularJS App - Toptal
angular-translate is an AngularJS module that provides filters and directives, along with the ability to load i18n data asynchronously.
Read more >
Angularjs – How to best organize translation strings in angular ...
I am breaking the project into multiple modules to make it more manageable, ... Using angular-translate, is there a way to load strings...
Read more >
Plato - service/loader-partial.js - Angular Translate
All parts you add by using this provider would be loaded by ... $log.warn('The partial loader has detected a multiple structure change (with ......
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