From 5d593ed399b89c3026ee20d565aac0e1f5808216 Mon Sep 17 00:00:00 2001 From: Alex McHardy Date: Tue, 8 Jun 2021 09:59:32 -0500 Subject: [PATCH] fix: Respect user-defined prefix/suffix when looking for default NS --- src/config/createConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/createConfig.ts b/src/config/createConfig.ts index dc753392..7a26c946 100644 --- a/src/config/createConfig.ts +++ b/src/config/createConfig.ts @@ -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)