Qwik Speak
  • README
  • Library
    • Quick Start
    • Tutorial: localized routing with the language
    • Tutorial: translated routing with url rewriting
    • Translate
    • Translation functions
    • Lazy loading translation
    • Qwik Speak and Adapters
    • Testing
  • Tools​
    • Qwik Speak Extract
    • Qwik Speak Inline Vite plugin
Powered by GitBook
On this page
Edit on GitHub
  1. Library

Lazy loading translation

PreviousTranslation functionsNextQwik Speak and Adapters

Last updated 1 year ago

If you are developing a large app, you can consider using lazy loading translation: translations that are lazy loaded only when requested (when the user navigates to a specific section or page of the app):

For lazy loading of files in a specific section, you need to add useSpeak to the layout:

import { useSpeak } from 'qwik-speak';

export default component$(() => {
  useSpeak({assets:['admin'], runtimeAssets: ['runtimeAdmin']});
  
  return (
    <>
      <main>
        <Slot />
      </main>
    </>
  );
});

or in a specific page:

export default component$(() => {
  useSpeak({runtimeAssets: ['runtimePage']});

  return <Page />;
});

Note that you must create a component for the page, because Qwik renders components in isolation, and translations are only available in child components