Angular 5-在TypeScript中翻译字符串 [英] Angular 5 - Translating Strings in TypeScript

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

问题描述

我正在使用i18n进行翻译,并对HTML方面的工作方式感到满意.

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?

推荐答案

直到现在(@angular/language-service v7.2),都无法通过库的API进行此操作.无论如何,您可以在另一个相似的问题下看到我的回答以寻求解决方法.

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.

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

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