Skip to content

Commit

Permalink
feat: update conflicting default translation message (#236)
Browse files Browse the repository at this point in the history
* Update conflicting default translation message

- Add the current default string to the log to make comparing / locating the conflicting
  key easier.

* ci: remove Node.js 12.x from build matrix

Co-authored-by: cheton <cheton@gmail.com>
  • Loading branch information
hogansghost and cheton committed Oct 14, 2022
1 parent 9e91b0c commit 0da3ed0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
10 changes: 5 additions & 5 deletions src/parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint no-console: 0 */
/* eslint no-eval: 0 */
import fs from 'fs';
import * as acorn from 'acorn';
import acornJsx from 'acorn-jsx';
import acornStage3 from 'acorn-stage3';
Expand All @@ -9,14 +8,15 @@ import cloneDeep from 'clone-deep';
import deepMerge from 'deepmerge';
import { ensureArray } from 'ensure-type';
import { parse } from 'esprima-next';
import fs from 'fs';
import i18next from 'i18next';
import _ from 'lodash';
import parse5 from 'parse5';
import sortObject from 'sortobject';
import i18next from 'i18next';
import jsxwalk from './acorn-jsx-walk';
import flattenObjectKeys from './flatten-object-keys';
import omitEmptyObject from './omit-empty-object';
import nodesToString from './nodes-to-string';
import omitEmptyObject from './omit-empty-object';

i18next.init({
compatibilityJSON: 'v3',
Expand Down Expand Up @@ -1046,15 +1046,15 @@ class Parser {
resLoad[resKey] = options.defaultValue;
} else if ((resLoad[resKey] !== options.defaultValue) && (lng === defaultLng)) {
// A default value has provided but it's different with the expected default
this.log(`The translation key ${chalk.yellow(JSON.stringify(resKey))} has a different default value, you may need to check the translation key of default language (${defaultLng})`);
this.log(`The translation key ${chalk.yellow(JSON.stringify(resKey))}, with a default value of "${chalk.yellow(options.defaultValue)}" has a different default value, you may need to check the translation key of default language (${defaultLng})`);
}
} else if (options.defaultValue_plural && resKey.endsWith(`${pluralSeparator}plural`)) {
if (!resLoad[resKey]) {
// Use `options.defaultValue_plural` if specified
resLoad[resKey] = options.defaultValue_plural;
} else if ((resLoad[resKey] !== options.defaultValue_plural) && (lng === defaultLng)) {
// A default value has provided but it's different with the expected default
this.log(`The translation key ${chalk.yellow(JSON.stringify(resKey))} has a different default value, you may need to check the translation key of default language (${defaultLng})`);
this.log(`The translation key ${chalk.yellow(JSON.stringify(resKey))}, with a default value of "${chalk.yellow(options.defaultValue_plural)}" has a different default value, you may need to check the translation key of default language (${defaultLng})`);
}
}

Expand Down

0 comments on commit 0da3ed0

Please sign in to comment.