@team-monolith/cds 1.117.4 → 1.117.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n/i18n.js +13 -11
- package/package.json +1 -1
package/dist/i18n/i18n.js
CHANGED
|
@@ -3,22 +3,23 @@ import LanguageDetector from "i18next-browser-languagedetector";
|
|
|
3
3
|
import Backend from "i18next-locize-backend";
|
|
4
4
|
import { COOKIE_NAME, I18N_COMMON_CONFIGS, QUERYSTRING_NAME, } from "./i18nConfigs";
|
|
5
5
|
import { initReactI18next } from "react-i18next";
|
|
6
|
-
const languageDetector = new LanguageDetector(null, {
|
|
7
|
-
lookupCookie: COOKIE_NAME,
|
|
8
|
-
lookupQuerystring: QUERYSTRING_NAME,
|
|
9
|
-
caches: [], // 사용자의 language 설정을 저장하지 않습니다.
|
|
10
|
-
});
|
|
11
|
-
const DETECTED_LANGUAGE = languageDetector.detect();
|
|
12
|
-
const CONTAINS_KOREAN = typeof DETECTED_LANGUAGE === "string"
|
|
13
|
-
? DETECTED_LANGUAGE.startsWith("ko")
|
|
14
|
-
: Array.isArray(DETECTED_LANGUAGE)
|
|
15
|
-
? DETECTED_LANGUAGE.some((lang) => lang.startsWith("ko"))
|
|
16
|
-
: false;
|
|
17
6
|
export function getI18nInstance(config) {
|
|
7
|
+
const languageDetector = new LanguageDetector(null, {
|
|
8
|
+
lookupCookie: COOKIE_NAME,
|
|
9
|
+
lookupQuerystring: QUERYSTRING_NAME,
|
|
10
|
+
caches: [], // 사용자의 language 설정을 저장하지 않습니다.
|
|
11
|
+
});
|
|
12
|
+
const DETECTED_LANGUAGE = languageDetector.detect();
|
|
13
|
+
const CONTAINS_KOREAN = typeof DETECTED_LANGUAGE === "string"
|
|
14
|
+
? DETECTED_LANGUAGE.startsWith("ko")
|
|
15
|
+
: Array.isArray(DETECTED_LANGUAGE)
|
|
16
|
+
? DETECTED_LANGUAGE.some((lang) => lang.startsWith("ko"))
|
|
17
|
+
: false;
|
|
18
18
|
const i18nextInstance = i18next.createInstance().use(initReactI18next);
|
|
19
19
|
if (!config) {
|
|
20
20
|
// config가 없는 경우, backend 플러그인 없이 기본 i18next 설정을 사용하여,
|
|
21
21
|
// fallbackValue(=key)를 항상 사용하게 됩니다.
|
|
22
|
+
console.log("[i18n] i18n config is not provided. Using default i18n instance.");
|
|
22
23
|
i18nextInstance.init(Object.assign(Object.assign({}, I18N_COMMON_CONFIGS), { fallbackLng: false }));
|
|
23
24
|
return i18nextInstance;
|
|
24
25
|
}
|
|
@@ -29,6 +30,7 @@ export function getI18nInstance(config) {
|
|
|
29
30
|
* 2. 언어 설정이 한국어가 아닐 때
|
|
30
31
|
*/
|
|
31
32
|
const LOCIZE_ENABLED = config.environment !== "production" || !CONTAINS_KOREAN;
|
|
33
|
+
console.log(`[i18n] Initializing i18n instance with config`);
|
|
32
34
|
(LOCIZE_ENABLED && config.projectId
|
|
33
35
|
? i18nextInstance.use(Backend)
|
|
34
36
|
: i18nextInstance).init(Object.assign(Object.assign({}, I18N_COMMON_CONFIGS), { debug: config.environment !== "production",
|