Skip to content

Commit

Permalink
Tools(inline): fix load translations
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed May 26, 2024
1 parent 0c3289e commit 07327e9
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/qwik-speak/tools/inline/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function qwikSpeakInline(options: QwikSpeakInlineOptions): Plugin {
enforce: 'post',
apply: undefined, // both

configResolved(resolvedConfig) {
async configResolved(resolvedConfig) {
if (resolvedConfig.build?.ssr || resolvedConfig.mode === 'ssr') {
target = 'ssr';
} else if (resolvedConfig.mode === 'lib') {
Expand All @@ -117,6 +117,12 @@ export function qwikSpeakInline(options: QwikSpeakInlineOptions): Plugin {
input = inputOption
}
input = input?.split('/')?.pop();

// Load translation files
await Promise.all(resolvedOptions.supportedLangs.map(async lang => {
const data = await resolvedOptions.loadAssets(lang);
Object.assign(translation[lang], data);
}));
},

configureServer(server) {
Expand Down Expand Up @@ -154,17 +160,6 @@ export function qwikSpeakInline(options: QwikSpeakInlineOptions): Plugin {
}
},

/**
* Load translation files when build starts
*/
async buildStart() {
// For all langs
await Promise.all(resolvedOptions.supportedLangs.map(async lang => {
const data = await resolvedOptions.loadAssets(lang);
Object.assign(translation[lang], data);
}));
},

/**
* Transform functions
* Prefer transform hook because unused imports will be removed, unlike renderChunk
Expand Down

0 comments on commit 07327e9

Please sign in to comment.