Skip to content

Commit

Permalink
fix(module): correct locale text input
Browse files Browse the repository at this point in the history
Resolves #46
  • Loading branch information
dargmuesli committed Feb 24, 2023
1 parent 58c7158 commit 8fe4402
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ export default defineNuxtConfig({
],
},
locales: ['en', 'de'],
localeTexts: {
de: {
iframeBlocked: 'Bitte funktionale Cookies aktivieren:',
},
},
},
})
5 changes: 4 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ const loadLocales = async (moduleOptions: ModuleOptions) => {
if (!text) throw new Error(`Could not import text for locale ${locale}`)

moduleOptions.locales.push(locale)
moduleOptions.localeTexts[locale] = text
moduleOptions.localeTexts[locale] = {
...text,
...moduleOptions.localeTexts[locale],
}
}

// const regex = new RegExp(moduleOptions.locales.join('|'))
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface ModuleOptions {
isDashInDescriptionEnabled: boolean
isIframeBlocked: boolean | { initialState: boolean }
locales: Locale[]
localeTexts: PartialRecord<Locale, LocaleStrings>
localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>
}

export const DEFAULTS: Required<ModuleOptions> = {
Expand Down

0 comments on commit 8fe4402

Please sign in to comment.