We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4d2cf8f commit 404f55bCopy full SHA for 404f55b
packages/runtime/plugin-i18n/src/runtime/i18n/detection/index.node.ts
@@ -19,7 +19,15 @@ export const detectLanguage = (
19
const detector = i18nInstance.services?.languageDetector;
20
if (detector && typeof detector.detect === 'function' && request) {
21
try {
22
- return detector.detect(request, {});
+ const result = detector.detect(request, {});
23
+ // detector.detect() can return string | string[] | undefined
24
+ if (typeof result === 'string') {
25
+ return result;
26
+ }
27
+ if (Array.isArray(result) && result.length > 0) {
28
+ return result[0];
29
30
+ return undefined;
31
} catch (error) {
32
console.warn('[@modern-js/plugin-i18n] Language detection failed', {
33
error,
0 commit comments