Using $translateProvider.useLoader, the addPart/refresh combination does not work properly for the frist element's translation.
See original GitHub issueHi Pascal,
Here is the config
.config(['$translateProvider', '$translatePartialLoaderProvider', function ($translateProvider, $translatePartialLoaderProvider) {
$translateProvider.useLoader('$translatePartialLoader', {
urlTemplate: 'i18n/{lang}/{part}.json'
});
$translateProvider.preferredLanguage('en-EN');
$translatePartialLoaderProvider.addPart('main');
}])
Tranlsation files are :- i18n/en-EN/main.json i18n/en-EN/pa.json i18n/fr-FR/main.json i18n/fr-FR/pa.json
The files have few common elements for example page heading is common in all files which refers to the heading of that particular page.
MainCtrl for mainview.html
angular.module('appApp')//organization-definition
.controller('MainCtrl', ['$scope', '$translate', '$translatePartialLoader',
function ($scope, $translate, $translatePartialLoader) {
$translatePartialLoader.addPart('main');
$translate.refresh();
}
]);
PaAddCtrl for paview.html
angular.module('appApp')
.controller('PaAddCtrl', ['$scope', '$translate', '$translatePartialLoader',
function ($scope, $translate, $translatePartialLoader) {
$translatePartialLoader.addPart('positions');
$translate.refresh();
}])
When the app starts, MainCtrl is the one so the language part sets up to main and it works fine. When I move to PaAddCtrl from MainCtrl, then the translation of first element does not come from the positions.json file but instead comes from the main.json file. And same thing happens when I move from PaAddCtrl’s paview.html to MainCtrl’s main.html.
What am I doing wrong? Can you please point it out and help me fix this?
Issue Analytics
- State:
- Created 10 years ago
- Comments:35 (15 by maintainers)
Top Results From Across the Web
Using $translateProvider.useLoader, the addPart/refresh ...
Using $translateProvider.useLoader, the addPart/refresh combination does not work properly for the frist element's translation.
Read more >Using $translate in service does not work - Stack Overflow
I want to use angular translate in service. I tried to load it using translatePartialLoader and then refresh but no success I am...
Read more >Applying markup to translations in Angular applications (the ...
Supporting translated text with markup in Angular applications is challenging. A proper solution is presented in this article.
Read more >Adding translation using angular-translate to an angularjs app
This post adds internationalisation (i18n) to the app using the angular-translate library. This library allows "on-the-fly" translation of ...
Read more >[SOLVED] Why angular-translate not working? - Ionic Forum
Hi, I installed angular-translate and angular-local-storage in my project which save in the path [project]/www/lib/.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@knalli, it seams that this issue is not resolved yet. I was unable to operate with the provided plunker. Also I did not look at the example on GitHub as it is huge and has a lot of directories.
But, there are at least two possible things which can lead to an unexpected behavior here.
refresh()
method is called. Also, at the moment we have additional tools to help to fight this situation: thegetRegisteredParts
method and priority of the parts.use()
andrefresh()
methods.Closed due inactivity. Enhancements for the partial loader already addressed in the linked issues.