Skip to content

Commit

Permalink
fix: Make create-config defaultFile use localeStructure (#934)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Allegrini <[email protected]>
  • Loading branch information
Francesco Allegrini and Francesco Allegrini authored Feb 4, 2021
1 parent 76280e4 commit 8b6d637
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/config/create-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const createConfig = (userConfig) => {
const {
allLanguages,
defaultLanguage,
defaultNS,
localeExtension,
localePath,
localeStructure,
Expand Down Expand Up @@ -62,8 +63,9 @@ export const createConfig = (userConfig) => {
Validate defaultNS
https://github.com/isaachinman/next-i18next/issues/358
*/
if (typeof combinedConfig.defaultNS === 'string') {
const defaultFile = `/${defaultLanguage}/${combinedConfig.defaultNS}.${localeExtension}`
if (typeof defaultNS === 'string') {
const defaultStructure = localeStructure.replace(/{{ns}}/g, defaultNS).replace(/{{lng}}/g, defaultLanguage)
const defaultFile = `/${defaultStructure}.${localeExtension}`
const defaultNSPath = path.join(localePath, defaultFile)
const defaultNSExists = fs.existsSync(defaultNSPath)
if (!defaultNSExists) {
Expand Down Expand Up @@ -119,7 +121,7 @@ export const createConfig = (userConfig) => {
addPath: `${clientLocalePath}/${localeStructure}.missing.${localeExtension}`,
}

combinedConfig.ns = [combinedConfig.defaultNS]
combinedConfig.ns = [defaultNS]
}

/*
Expand Down

0 comments on commit 8b6d637

Please sign in to comment.