Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface I18nConfig extends NextI18nConfig {
keySeparator?: string | false
nsSeparator?: string | false
defaultNS?: string
fallbackNS?: string
allowEmptyStrings?: boolean
}

Expand Down
8 changes: 8 additions & 0 deletions src/transCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export default function transCore({
}
}

// defaultNS fallback
if (empty && config.fallbackNS) {
const new_key = `${config.fallbackNS}:${i18nKey}`
if (new_key !== i18nKey && new_key != `${namespace}:${i18nKey}`) {
return t(new_key, query, { ...options })
}
}

if (empty && options?.default && fallbacks?.length == 0) {
return interpolation({ text: options?.default, query, config, lang })
}
Expand Down