javascript - Angular-gettext 从 javascript 文件中提取注释

标签 javascript angularjs translation gettext po

Angular-gettext we extract annotated strings from htmlGruntfile.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/

相关文章:

javascript - 在 Angular Material 中提交选择选项值

angularjs - 错误 : 10 $digest() iterations reached. 正在中止!使用动态排序谓词

javascript - 构建 opencv.js 时如何包含 cv.imread()?

javascript - 用javascript动态调用类的方法

javascript - 使用 Node.JS 和 AngularJS 在 HTML 中显示 Redis 值

php - I18n 使用 PHP gettext()

php - 如何在 prestashop Controller 中使用翻译?

c - 将 C 转换为 IA-32 汇编 - 比较 w/2 条件

javascript - Vuejs set方法返回模板

javascript - 如何将超时添加到当前 slider 代码?