Angular 5 - Translating Strings in TypeScript

北慕城南 提交于 2019-12-06 01:08:05

问题


I am using i18n for my tranlsations and am happy with how this works on the html side.

However if I have error messages etc defined in strings in my typescript I would like a way to translate these and can't find a way to do it.

Is there a workaround to achieve this?


回答1:


This is not possible through the library's API until now (@angular/language-service v7.2). Anyway, you can see my answer under another similar question for a workaround.




回答2:


There is an open question on Angular GitHub repo.

For more info, check this out. Unfortunately, typescript's strings are not supported yet officially. However, some devs proposed a few workarounds you could take a look at.



来源:https://stackoverflow.com/questions/47591831/angular-5-translating-strings-in-typescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!