Closed lsantaniello closed 7 years ago
You should have a look into the developer console! Maybe your relative path to the template is an issue?
Hello,
this is a general reminder: We are still waiting for your reply with additional details. If you cannot help us, we cannot help you.
Looking forward to hear from you.
@tspaeth @knalli Hello, I have some problems with this.
// ====== app.config.js ======
$translateProvider.useLoader('translationLoader', {
files: [
{
languageKey: 'en-US',
shortKey: 'en',
},
{
languageKey: 'zh-CN',
shortKey: 'zh',
},
{
languageKey: 'zh-HK',
shortKey: 'hk',
}
]
});
$translateProvider.useSanitizeValueStrategy('sanitize');
// $translateProvider.translations('zh-CN', i18n.zh);
// $translateProvider.translations('en-US', i18n.en);
// $translateProvider.translations('zh-HK', i18n.hk);
$translateProvider.preferredLanguage(i18n.lang);
// ====== translateLoader.service.js ======
class TranslateLoader {
constructor() {
this.langs = {};
}
$get($http, $q, co) {
'ngInject';
const provider = this;
return options=> {
let files = options.files || [];
let key = options.key;
let localeFile = _.find(files, v=>v.languageKey === key);
return co(function*() {
if (!localeFile) return yield $q.reject(options.key);
let fileName = `${localeFile.shortKey}.locale.json`;
if (!fileName) return yield $q.reject();
let resp = yield $http(angular.extend({
url: '/assets/locale/' + fileName,
method: 'GET'
}, options.$http));
let lang = resp.data;
provider.langs[key] = lang;
return yield $q.resolve(lang);
}).catch(function (err) {
console.error(err);
return $q.reject(err);
});
};
}
}
export {TranslateLoader};
The problems is: it will work in Chrome, not work at Firefox.
in the Chrome runtime, it will load the lang-pack and init the program. all work like expect. but in Firefox, it will load the lang-pack too, but it will not init, all HTML is origin code.
{
"hello": "hello world"
}
<h1>{{'hello' | translate}}</h1>
<!-- chrome has been compile -->
<h1>hello world</h1>
<!-- firefox not compile at all -->
<h1>hello</h1>
@axetroy Please ask "how do I..." questions on Stackoverflow and please don't "hijack" an existing ticket with a probably different scenario. File a question on http://stackoverflow.com/questions/tagged/angular-translate - you'll reach a bigger audience (including a plunker).
This issue tracker is mainly the feature-/bugtracker for angular-translate. But you're always free to add a feature request later on.
Thanks.
Hello,
I'm closing this issue due inactivity. We have asked for additional details, but you could not helped us. Therefore we close this issue as not reproducible.
If you still have an issue, please create a new issue because we cannot be sure to track closed issues.
Hi guys, I integrated angular-translate in my ionic app but I have a problem with loading language files.
I included into my index.html file these scripts:
I created new folder lang that contains:
If I use static definition, it works:
$translateProvider.translations('en', { 'TITLE': 'Hello', 'FOO': 'This is a paragraph' }); $translateProvider.translations('de', { 'TITLE': 'Hallo', 'FOO': 'Dies ist ein Absatz' });
If I use loader, it doesn't work. ` .config(['$translateProvider', function ($translateProvider, $translatePartialLoaderProvider ) {My i18n files contains:
{ 'TITLE': 'Ciao', 'FOO': 'Prova' }
My html file: `
{{ 'TITLE' | translate }}
{{ 'FOO' | translate }}
` How can I catch the error? ### My environment - angular-translate - v2.12.0 - 2016-09-05 Thanks for your help Luca