2

アプリに i18n を実装するために angular-gettext を使用したいのですが、これに従いましたhttp://lostechies.com/gabrielschenker/2014/02/11/angularjspart-12-multi-language-support/ このコマンドを使用しました:

  npm install -g grunt-cli
  npm install grunt
  npm install grunt-angular-gettext

私の Gruntfile.js :

 module.exports=function(grunt){
grunt.loadNpmTasks('grunt-angular-gettext');
//This task will parse all our source files and extract the texts we want to have translated – the ones that have an associated translate directive – and add them to a so called pot file.
grunt.initConfig({
    nggettext_extract:{ //we define the task name we want to configure or initialize
        pot:{
            files:{
                'po/template.pot':['../templates/*.html'] //we want the task to parse all html files in the current directory or any sub directory of it and output the result of the task into a file called template.pot
            }
        }
    },
    nggettext_compile:{
        all:{
            files:{
            'translations.js':['po/*.po'] //we want this task to load all po files in the subfolder po of the current directory and compile them into a resulting file translations.js located in the current directory.
            }
        }
        }
});

  }

このコマンド grunt nggettext_extract を使用して翻訳を抽出すると、次のエラーが発生します。

  >> Local Npm module "grunt-angular-gettext" not found. Is it installed?
   Warning: Task "nggettext_extract" not found. Use --force to continue.

   Aborted due to warnings.

どうしてか分かりません?パッケージ grunt-angular-gettext がノード モジュールに存在します。これに対処するのを手伝ってもらえますか?

4

3 に答える 3

1

これが役立つかどうかはわかりませんが、同じエラーが発生していました。しばらく調べたところ、grunt.initConfig の nggettext_extract エントリが正しくないことに気付きました。レベルが間違っていました (誤ってシェル内に入れました)、それはあなたの問題ではないことがわかりますが、それでも Gruntfile に何かある可能性があります。

于 2014-03-26T16:08:33.277 に答える
1

解決策は、まずディレクトリに package.json ファイルがあることを確認することです。

実行: npm init 次に npm install grunt npm install grunt-angular-gettext

これにより、実際のモジュールがインストールされます。このトピックの詳細については、https ://github.com/gruntjs/grunt/issues/232 を参照してください。

于 2016-01-14T15:12:26.177 に答える