使用i18next模块时出现Google Apps脚本错误

Nod*_*dov 6 javascript google-apps-script ecmascript-6 i18next

我在ES6中编写我的项目,目前面临i18next模块的问题.https://www.i18next.com/

在我的本地系统上,当我导入i18next import i18next from 'i18next';并在我的源文件中使用它时一切正常.但是在我运行之后npm run gulp(它将所有源文件合并到一个javascript文件 - main.js中)并尝试将该代码上传到Google Apps脚本(使用gapps upload),它失败并出现Bad Request. Upload failed.错误.

在线检查后我发现这个错误意味着语法有问题,所以我尝试将main.js中的代码粘贴到google apps脚本中,它显示以下语法错误:

无效的属性ID.(第32行,文件"main")

第32行:

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Run Code Online (Sandbox Code Playgroud)

即使我只导入i18next模块而没有实际执行任何操作,也会发生此错误.

这是我的gulpfile:

import gulp from 'gulp';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import mocha from 'gulp-mocha';

const compileFile = 'main.js';

gulp.task('dest', () => {
    browserify({
        entries: ['src/'+compileFile]
    })
    .transform('babelify')
    .plugin('gasify')
    .bundle()
    .pipe(source(compileFile))
    .pipe(gulp.dest('dist'));
});

gulp.task('test', () => {
    gulp.src('test/**/*.js', {read: false})
    .pipe(mocha({
        reporter: 'spec',
        compilers: 'js:babel-core/register'
    }));
});

gulp.task('default', ['test', 'dest'], () => {});

gulp.task('watch', () => {
    gulp.watch('src/**/*.js', ['dest']);
});
Run Code Online (Sandbox Code Playgroud)

也尝试使用i18n模块,不起作用.

我想为我的翻译使用get text模块,不需要货币/日期格式自定义.只是来自翻译文件的文本获取器.不能使用json po或任何其他扩展(我需要将所有文件作为一个文件上传到GAS,不要认为它们允许除.js之外的任何文件)

我的模板文件是这样的en.js:

const res = {
  template: {
    "signIn":"Hello, <@#1>! Signed you in (#2)",
    ...
  },
  command: {
    "signIn": "hi",
    ...
  }
};
export default res;
Run Code Online (Sandbox Code Playgroud)

Nod*_*dov 6

刚刚找到了工作方案!

在尝试了所有的国际化库并获得各种气体和非农业相关的错误之后,node-polyglot模块为我工作了!

仍然不知道为什么i18next不工作的原因