【问题标题】:Angular-gettext extract annotations from .cshtml fileAngular-gettext 从 .cshtml 文件中提取注释
【发布时间】:2014-09-24 20:43:01
【问题描述】:

我正在使用Angular-gettext to extract strings from .html.js files 使用Gruntfile.js 进行多语言翻译:

  grunt.initConfig({
    nggettext_extract: {
      pot: {
        files: {
          'po/template.pot': ['**/*.html', '**/*.cshtml', '**/controller.caseload.js']
        }
      },
    }

但是当我尝试从 .cshtml 文件中提取时,它并没有被提取。

我需要从我的 Header.cshtml 文件中提取,因为我将它用作我的 Angular 应用程序的布局。该布局基本上在每个页面的顶部显示一个标题栏,其中包含用户信息(个人资料、首选项、注销等)。

当我尝试将<div translate>Preferences<div> 之类的行添加到我的 Header.cshtml 文件中时,它不会提取到我的 .pot 文件中。但是,如果我将同一行添加到我的 index.html 文件中,它会正确提取,然后我就可以为其定义翻译。

对于 .cshtml 文件是否有使用 angular-gettext 的好方法?

【问题讨论】:

  • 如果您找到解决方案,请发布您的解决方案。我在同一条船上。

标签: asp.net-mvc angularjs razor gettext po


【解决方案1】:

尝试将此代码添加到您的选项部分。

            options: {
                extensions: {
                    htm: 'html',
                    html: 'html',
                    php: 'html',
                    phtml: 'html',
                    tml: 'html',
                    js: 'js',
                    cshtml: 'html'
                }

默认情况下,它可能会尝试将您的模板解析为 Javascript。

【讨论】:

  • 完美,谢谢!我在锅部分之前添加了您的选项部分,现在所有内容都已正确提取。
猜你喜欢
  • 2014-10-12
  • 2021-12-11
  • 2013-11-19
  • 2021-11-28
  • 2012-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-20
相关资源
最近更新 更多