I am writing my project in ES6 and am currently facing a problem with the i18next module. https://www.i18next.com/
On my local system, when I import i18next import i18next from 'i18next'; and use it in my source files, everything works. However, after running npm run gulp (it combines all the source files into a single javascript file - main.js) and tries to load this code into the Google Apps script (using gapps upload ), it does not work with a Bad Request. Upload failed. error Bad Request. Upload failed. Bad Request. Upload failed. .
After checking on the Internet, I found that this error means that something is wrong with the syntax, so I tried to copy the code from main.js into google apps script and it displays the following syntax error:
Invalid property id. (Line 32, file "main")
Line 32:
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
This error occurs even if I import only the i18next module without doing anything with it.
Here is my 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']); });
Also tried using the i18n module, not working.
I want to use a text module for my translations, I do not need to configure the currency / date format. Just a text getter from translation files. It is impossible to use json po or any other extension (I will need to upload everything as one file in GAS, I don’t think they allow any files except .js)
my template files look like en.js :
const res = { template: { "signIn":"Hello, <@#1>! Signed you in (#2)", ... }, command: { "signIn": "hi", ... } }; export default res;