[英]Angular 9 $localize not working with --configuration=de
When using $localize from "@angular/localize/" with " ng serve --configuration=de " i get this:当使用来自“@angular/localize/”的 $localize 和“ ng serve --configuration=de ”时,我得到了这个:
It works perfect when running the project with just " ng serve ".仅使用“ ng serve ”运行项目时,它就可以完美运行。
in app.component.ts在 app.component.ts 中
public product: TabDefinition = { name: $localize`Products`, route: "/products" };
in Polyfills.ts在 Polyfills.ts 中
import "@angular/localize/init";
import { loadTranslations } from "@angular/localize";
loadTranslations({
"6707361102856436710": "Produkte",
});
What i have done is make a TranslationComponent
, as long as you specify the id in the template and in the $localize
call it will map correctly我所做的是制作一个
TranslationComponent
,只要您在模板中指定 id 并且在$localize
调用中它就会正确映射
<p i18n="@@pending-changes">You have unsaved changes are you sure you want to navigate?</p>
return confirm($localize`:@@pending-changes:You have unsaved changes are you sure you want to navigate?`);
<trans-unit id="pending-changes" datatype="html">
<source>You have unsaved changes are you sure you want to navigate?</source>
<target state="translated">Vous avez des modifications non enregistrées, êtes-vous sûr de vouloir naviguer?</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/shared/component/translations/translations.component.html</context>
<context context-type="linenumber">1</context>
</context-group>
</trans-unit>
Cheers干杯
Did you add this你加了这个吗
import '@angular/localize/init';
to your polyfills.ts file?到你的 polyfills.ts 文件?
Maybe there is path problem.可能是路径问题。 Try this:
尝试这个:
import '../node_modules/@angular/localize/init';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.