Skip to content

Commit

Permalink
fix: Respect user-defined prefix/suffix when looking for default NS
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmchardy committed Jun 8, 2021
1 parent c83e746 commit 5d593ed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/config/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export const createConfig = (userConfig: UserConfig): InternalConfig => {
// https://github.com/isaachinman/next-i18next/issues/358
//
if (typeof defaultNS === 'string' && typeof lng !== 'undefined') {
const defaultLocaleStructure = localeStructure.replace('{{lng}}', lng).replace('{{ns}}', defaultNS)
const prefix = userConfig?.interpolation?.prefix ?? '{{'
const suffix = userConfig?.interpolation?.suffix ?? '}}'
const defaultLocaleStructure = localeStructure.replace(`${prefix}lng${suffix}`, lng).replace(`${prefix}ns${suffix}`, defaultNS)
const defaultFile = `/${defaultLocaleStructure}.${localeExtension}`
const defaultNSPath = path.join(localePath, defaultFile)
const defaultNSExists = fs.existsSync(defaultNSPath)
Expand Down

0 comments on commit 5d593ed

Please sign in to comment.