我有一个使用AngularJS和angular-translate的应用程序来提供本地化。该应用目前仅使用英语和德语。
在登录页面上是必填字段,电子邮件。如果出现错误,应用程序将以英语显示“需要有效的电子邮件”。
用德语(原谅我,如果这是错误的,这是谷歌翻译,我不知道任何德语)这句话是“EinegültigeE-Mail erforderlich”。
在第二个词中,你会注意到一个国际角色,它看起来像一个“u”,上面有两个小点。当应用程序设置为以德语显示时,该角色会被转义并且屏幕上会出现很多怪异。
看看文档,似乎使用$ translateProvider.useSanitizeValueStrategy()应该处理这个,但事实并非如此。如果我使用$ translateProvider.useSanitizeValueStrategy('escaped'),那么它在屏幕上看起来像这样:
如果使用$ translateProvider.useSanitizeValueStrategy('sanitize')(我当然更喜欢),那么它看起来像这样:
我也偶然遇到this article,它指出我的* .js翻译文件需要UTF-8编码。我在NotePad ++中打开了该文件,将编码更改为UTF-8而没有BOM并保存,但我仍然看到错误。 VS现在真的讨厌这个文件。
答案 0 :(得分:0)
I know, it's a little late, but maybe others have similar Problems:
Adressing the UI:
Are you using the attribute style e.g.
<span translate="key"><span>
or inline style
<span>{{key | translate}}</span>
in your view?
I am working with the second style without issues.
Addressing your Problem with UTF-8:
I am not using Visual Studio nor Notepad++, so I don't know how Notepad++ handles the conversion. Possibly it does not convert the characters at all, but only changes the file to be seen as UTF-8.
Sublime Text 2 (1), on the other hand, offers you to 'Save with Encoding', which converts all characters accordingly. I stressed this conversion pretty much, so that I can recommend this approach with a clean conscience.
(1) I have no relations to Sublime Text, this is not meant be any form of commercial advertisement