在 Angular Typescript 代码中翻译字符串 [英] Translate strings inside Angular Typescript code

查看:28
本文介绍了在 Angular Typescript 代码中翻译字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Angular6 的组件源代码中翻译字符串.

Is it possible to translate strings inside the source code of a component in Angular6.

F.e.

window.confirm("HELP me");

除了 HTML 文件的正常翻译之外,我什么也没找到(Angular Docs i18n).

I haven't found anything besides the normal translation for the HTML files (Angular Docs i18n).

提前致谢

推荐答案

您可以使用 https://github.com/ngx-translate/i18n-polyfill 直到 Angular i18n 获得对它的内置支持,大概在第 9 版左右.作者正在研究 Angular i18n,所以我认为信任他的期望它会接近 Angular i18n 中的未来特性.

You can use https://github.com/ngx-translate/i18n-polyfill until Angular i18n get built-in support for it, probably around version 9. The author is working on Angular i18n, so I think it is safe to trust his expectation that it will be close to the future feature in Angular i18n.

本期有很多关于 Angular i18n 未来的有趣信息:https://github.com/angular/angular/issues/16477

There is a lot of interesting information about the future of Angular i18n in this issue: https://github.com/angular/angular/issues/16477

这篇关于在 Angular Typescript 代码中翻译字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆