简体   繁体   English

在.po转换文件中使用ui-sref获取angular-gettext

[英]Use ui-sref in .po translation file for angular-gettext

everyone. 大家。 Here is my issue. 这是我的问题。

I use angular-gettext for translations and in my HTML I got 我使用angular-gettext进行翻译,在HTML中,

<span ng-bind-html="myCtrl.textToTranslate|translate"></span>

in my en-EN.po file I have: 在我的en-EN.po文件中,我有:

msgid "Text to translate"
msgstr "This is <strong>my text</strong> "
"to translate and I want to use a link that "
"redirects me <a ui-sref="app.link.to.go">here</a>."

I managed to use the html tags as <strong></strong> in the translated version and it works, but the angular ui-sref redirect doesn't work. 我设法在翻译版本中将html标签用作<strong></strong> ,并且可以使用,但是有角度的ui-sref重定向不起作用。 The result in the browser is <a>here</a> 在浏览器中的结果是<a>here</a>

I suppose it's some kind of quotes issue or something.. I tried with backslash escaping and single quotes ui-sref=\\"app.link.to.go\\" & ui-sref='app.link.to.go' but without success. 我想这是某种形式的引号问题。.我尝试使用反斜杠转义和单引号ui-sref=\\"app.link.to.go\\"ui-sref='app.link.to.go'但是没有成功。

Any ideas? 有任何想法吗?

Angular has to compile html to process directives, so the translated string needs to be compiled prior to inserting it to DOM. Angular必须将html编译为处理指令,因此在将转换后的字符串插入DOM之前需要对其进行编译。 You can either call translate and then compile in your controller or create a new directive like bind-compiled-html that will call translate on the html contents. 您可以调用translate然后在控制器中进行编译,也可以创建一个新的指令(如bind-compiled-html来对html内容进行调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM