与 Angular-gettext we extract annotated strings from html在 Gruntfile.js
中指定:
grunt.initConfig({
nggettext_extract: {
pot: {
files: {
'po/template.pot': ['src/views/*.html']
}
},
},
})
是否也可以从 javascript 文件中提取字符串?
我有一个例子,我从 angularjs Controller 生成字符串:
<textarea ng-model="generatedCSV"></textarea>
CSV 的标题行是:
"Full Name", "Email"
需要翻译成其他语言。
有没有用 angular-gettext 做这个的好方法?
最佳答案
编辑:对于 future 的读者:也请阅读 OP 对此的评论,因为它包含有用的信息。
根据网站(我玩过angular-gettext,但没有使用过这个功能):
http://angular-gettext.rocketeer.be/dev-guide/annotate-js/
If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so:
angular.module("myApp").controller("helloController", function (gettext) {
var myString = gettext("Hello");
});
The Hello string will be added to your .pot file using the code above.
你试过吗?
关于javascript - Angular-gettext 从 javascript 文件中提取注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25374317/