i18next-parser
i18next-parser copied to clipboard
input tag is not executing
Hello, I am trying to extract keys from json and app.tsx file gulpfile.js is as below:
const gulp = require('gulp');
const i18nextParser = require('i18next-parser').gulp;
gulp.task('i18next', async function () {
gulp
.src('../../App.tsx')
.pipe(
new i18nextParser({
locales: ['en','hi'],
output: 'i18next/translations.json',
input: '../en/common.json',
}),
)
.pipe(gulp.dest('assets'));
});
but not reading single key from common.json and path is right, how to resolve this issue
You don't need input
since you have .src()
. Make a glob that parses both files.
hello @karellm,
structure and App.tsx is extracting keys but not from App.json please suggest any solution to resolve this issue
below is my gulp file and trying to extract keys from App.tsx and common.json
const gulp = require('gulp');
const i18nextParser = require('i18next-parser').gulp;
gulp.task('i18next', async function () {
gulp
.src('../../App.tsx')
.pipe(
new i18nextParser({
locales: ['en','hi'],
output: 'i18next/extractor.json',
}),
)
.pipe(gulp.dest('assets'));
});
and common.json file is as below:
{
"ok": "OK",
"cancel": "Cancel",
"userBill":
"Hey {{ user.username }}, your account has been generated Rs {{ userBill.total }} to pay",
}
Below is my App.tsx file
<Section title="INTERPOLATION">
<Text>{t('userBill', {user, userBill})}</Text>
</Section>
and below is extraction.json file which is only reading App.tsx file
{
"userBill": "",
}
I believe your are misunderstanding the input
and output
options. input
is the same as gulp.src
and exists for people running the parser from the command line with a config file. In your case, you don't need it.
Since you want to use the existing translations in common.json
, you need to point this file as the output. Otherwise the parser has no way to even know this file exists. Another option is to copy paste its content inside extractor.json
and leave your configuration as is.
gulp.task('i18next', async function () {
gulp
.src('../../App.tsx')
.pipe(
new i18nextParser({
locales: ['en','hi'],
output: 'wherever-is-your/common.json',
}),
)
.pipe(gulp.dest('assets'));
});