Skip to content

fix(i18n): allow localization of early loading states via useStaticTranslation#590

Open
kheireddinebou wants to merge 1 commit intoembedpdf:mainfrom
kheireddinebou:feat/use-static-translation
Open

fix(i18n): allow localization of early loading states via useStaticTranslation#590
kheireddinebou wants to merge 1 commit intoembedpdf:mainfrom
kheireddinebou:feat/use-static-translation

Conversation

@kheireddinebou
Copy link
Copy Markdown

Description

This PR fixes the issue where the early rendering states of the PDF viewer ("Initializing PDF engine...", "Initializing plugins...") are always displayed in English, regardless of the user's localized configuration.

Because loading indicators appear before the plugin system and dynamic translation hooks (useTranslations) are fully mounted, a static capability is needed to resolve simple translations from the configuration object synchronously.

Implementation Details

  • Introduced a new hook/composable: useStaticTranslation inside @embedpdf/plugin-i18n.
  • This hook takes the locales and defaultLocale from the config and manually traverses the translation keys statically.
  • Refactored framework implementation examples (React, Vue, Svelte) to leverage this static resolver, successfully replacing hardcoded English texts with their localized counterparts on mount.
  • Updated documentation (React, Vue, Svelte .mdx files) and the CHANGELOG.md to reflect the availability of the new useStaticTranslation function.

Related Issue

Closes #589

Pull Request Checklist

  • Followed the existing code style
  • Included comments in the code where necessary
  • Updated documentation to reflect the new useStaticTranslation functionality
  • Kept the pull request focused on this single fix
  • Verified changes build and compile correctly (pnpm build:watch)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

@kheireddinebou is attempting to deploy a commit to the OpenBook Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading text remains in English regardless of configured locale

1 participant