From 07e862f8d2518fb1b911ec1ab6fdcd27d77f62a9 Mon Sep 17 00:00:00 2001 From: Linda Bopp <151019977+BoppLi@users.noreply.github.com> Date: Fri, 19 Jan 2024 15:15:10 +0100 Subject: [PATCH] feat(i18n): do not reset i18n when provided (#154) ## Description Before, the i18n instance was resetted even if it has been provided. This PR fixes the issue. --- .changeset/brave-lobsters-wonder.md | 5 +++++ packages/sit-onyx/src/i18n/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/brave-lobsters-wonder.md diff --git a/.changeset/brave-lobsters-wonder.md b/.changeset/brave-lobsters-wonder.md new file mode 100644 index 000000000..9f5f02b46 --- /dev/null +++ b/.changeset/brave-lobsters-wonder.md @@ -0,0 +1,5 @@ +--- +"sit-onyx": patch +--- + +Ensure that the i18n instance is not reset when it has been provided diff --git a/packages/sit-onyx/src/i18n/index.ts b/packages/sit-onyx/src/i18n/index.ts index 05796e5b6..34b8a0473 100644 --- a/packages/sit-onyx/src/i18n/index.ts +++ b/packages/sit-onyx/src/i18n/index.ts @@ -87,10 +87,10 @@ export const provideI18n = (options: ProvideI18nOptions) => { /** * Injects the onyx i18n instance. + * Creates a fallback if provide was never called. */ export const injectI18n = () => { - const fallbackInstance = createI18n(); - return inject(I18N_INJECTION_KEY, fallbackInstance); + return inject(I18N_INJECTION_KEY, () => createI18n(), true); }; /**