我更新了我的应用程序的源代码,从Angular6到Angular12 -是的,我错过了它来更频繁地更新它。
现在,IU语言不再改变了。我正在使用i18n。看来html并没有应用翻译。因为我仍然可以从API加载XLF文件,但是翻译没有显示在UI中。
在这个角度应用程序中,我必须遵循我的main.ts中的代码:
const httpClient: HttpClient = injector.get(HttpClient);
httpClient.get(localizationUrl, {responseType: "text"})
.subscribe(res => {
const translations = res;
let locale = "de-DE";
let respCulture = /(?:(?:target-language)="([\w-]+)")/i.exec(translations);
if (respCulture)
locale = respCulture[1];
platformBrowserDynamic().bootstrapModule(AppModule, {
// missingTranslation: MissingTranslationStrategy.Warning,
providers: [
{provide: LOCALE_ID, useValue: locale},
{provide: TRANSLATIONS, useValue: translations},
{provide: TRANSLATIONS_FORMAT, useValue: "xlf"}
]
});
},
error => console.log(error));
区域设置总是"de",我也尝试过"de-DE“,但是它并没有改变行为。在我的html中,我使用的i18n如下:
<h3 i18n="@@settings-tab-header">You will receive your incoming invoices automatically in PDF format.</h3>
我试图找一个问题,比较我的代码和https://angular.io/guide/i18n,但我找不到任何东西。我还试着评论"provide: LOCALE_ID.“以及“提供:TRANSLATIONS_FORMAT.”但这对我没什么帮助。
有人有什么想法吗?
谢谢!
发布于 2021-06-01 11:49:58
我现在通过在应用程序中提供翻译来解决这个问题。因此,我失去了在没有应用程序部署的情况下更改翻译的好处。
https://stackoverflow.com/questions/67632168
复制相似问题