Open CarrotIronfoundersson opened 3 years ago
Describe the bug Extracted keys include extra symbols at the front when nsSeparator is set to more then 1 symbol.
How to reproduce Set nsSeparator to more then 1 symbol, like double colon nsSeparator: '::'
nsSeparator: '::'
Babel configuration:
{ "presets": ["@babel/preset-react"], "plugins": [ "@babel/plugin-proposal-class-properties", "@babel/plugin-syntax-dynamic-import", [ "i18next-extract", { "locales": ["fr"], "defaultNS": "common", "keySeparator": null, "nsSeparator": "::", "defaultValue": null } ] ] }
Reproduction:
import { useTranslation } from 'react-i18next'; const { t } = useTranslation('customers', 'common'); {t('common::Cancel')}; {t('common::OK')}; {t('common::Close')}
Expected behavior common.json:
{ "Cancel": null, "Close": null, "OK": null }
What actually happens
{ ":Cancel": null, ":Close": null, ":OK": null }
Your environment
Workarounds In node_modules\babel-plugin-i18next-extract\index.js
function parseExtractedKey(key, config), line 1685 :
Before:
cleanKey = cleanKey.slice(nsSeparatorPos + 1);
After:
cleanKey = cleanKey.slice(nsSeparatorPos + config.nsSeparator.length);
Encountering the same issue here.
Describe the bug Extracted keys include extra symbols at the front when nsSeparator is set to more then 1 symbol.
How to reproduce Set nsSeparator to more then 1 symbol, like double colon
nsSeparator: '::'
Babel configuration:
Reproduction:
Expected behavior common.json:
What actually happens
Your environment
Workarounds In node_modules\babel-plugin-i18next-extract\index.js
function parseExtractedKey(key, config), line 1685 :
Before:
After: