Skip to content

Commit

Permalink
Move i18next-parser config to a separate file (#451)
Browse files Browse the repository at this point in the history
In their infinite wisdom, the i18next-parser team decided to go ESM-
only, which obviously doesn't work with a TS gulpfile that is still
emulating ESM on top of CommonJS. Sigh.
  • Loading branch information
jgonggrijp committed Apr 20, 2022
1 parent e63744b commit 91ad84b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
17 changes: 0 additions & 17 deletions frontend/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { argv } from 'yargs';
import { JSDOM, VirtualConsole } from 'jsdom';
import * as through2 from 'through2';
import chalk from 'chalk';
import { gulp as i18nextParser } from 'i18next-parser';
import HbsI18nLexer from 'handlebars-i18next-parser';


type LibraryProps = {
Expand Down Expand Up @@ -96,7 +94,6 @@ const sourceDir = `src`,
hbsGlobal = 'Handlebars',
i18nModuleTail = 'dist/umd/i18next',
i18nModule = `i18next/${i18nModuleTail}`,
i18nDir = `${sourceDir}/i18n`,
styleDir = `${sourceDir}/style`,
mainStylesheet = `${styleDir}/main.sass`,
styleSourceGlob = `${styleDir}/*.sass`,
Expand Down Expand Up @@ -291,18 +288,6 @@ function reportBundleError(errorObj) {
log.error(chalk.red(errorObj.message));
}

export function i18nParse() {
return src(`${sourceDir}/**`)
.pipe(new i18nextParser({
locales: ['en', 'fr'],
output: `${i18nDir}/$LOCALE/$NAMESPACE.json`,
lexers: {
hbs: [HbsI18nLexer],
},
}))
.pipe(dest('.'));
}

function jsBundle() {
return tsModules().bundle()
.on('error', reportBundleError)
Expand Down Expand Up @@ -504,8 +489,6 @@ export const watch = series(fullStatic, function watch(done) {
retest(reloadPr(specRunner.render))
);

// i18nParse();

exitController.once('signal', () => {
[
tsModules(), tsTestModules(), reporterModules(), styleWatch,
Expand Down
13 changes: 13 additions & 0 deletions frontend/i18next-parser.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import HbsI18nLexer from 'handlebars-i18next-parser';

const sourceDir = 'src';
const i18nDir = `${sourceDir}/i18n`;

export default {
input: [`${sourceDir}/**/*.{t,hb}s`, `!${sourceDir}/**/*-te{mplate,st}.ts`],
output: `${i18nDir}/$LOCALE/$NAMESPACE.json`,
locales: ['en', 'fr'],
lexers: {
hbs: [HbsI18nLexer],
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"watch-front": "yarn gulp watch --port 8000 --config ../config.json",
"watch-front-notest": "yarn gulp watchNoTest --port 8000 --config ../config.json",
"start": "yarn watch-front & yarn serve-back & yarn watch-back",
"localize": "yarn front yarn i18next -c i18next-parser.config.mjs",
"dist": "yarn gulp dist",
"dist-p": "yarn dist --production --config ../config.json",
"collectstatic-p": "yarn django collectstatic -v 0 --settings production --pythonpath ..",
Expand Down

0 comments on commit 91ad84b

Please sign in to comment.