@team-monolith/cds 1.117.8 → 1.117.9

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.
@@ -5,7 +5,7 @@ import { COLOR } from "./foundation/color";
5
5
  import { FONT } from "./foundation/font";
6
6
  import { createTheme } from "@mui/material";
7
7
  import { createContext, useMemo } from "react";
8
- import { getI18nInstance } from "./i18n/i18n";
8
+ import { createAndInitI18nInstance } from "./i18n/i18n";
9
9
  import { I18nextProvider } from "react-i18next";
10
10
  export const light = {
11
11
  fontFamily: {
@@ -311,7 +311,7 @@ export const dark = {
311
311
  };
312
312
  export const CdsContext = createContext({});
313
313
  export function CdsProvider(props) {
314
- const i18nInstance = useMemo(() => getI18nInstance(props.i18nextConfig), []);
314
+ const i18nInstance = useMemo(() => createAndInitI18nInstance(props.i18nextConfig), []);
315
315
  const muiTheme = createTheme({
316
316
  typography: {
317
317
  fontFamily: props.fontFamily,
@@ -5,4 +5,4 @@ export type i18nextConfig = {
5
5
  projectId: string;
6
6
  apiKey?: string;
7
7
  };
8
- export declare function getI18nInstance(config: i18nextConfig | undefined): i18n;
8
+ export declare function createAndInitI18nInstance(config: i18nextConfig | undefined): i18n;
package/dist/i18n/i18n.js CHANGED
@@ -3,24 +3,25 @@ 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;
6
17
  // AIDEV-NOTE: CDS 안에서 i18n 인스턴스를 1개만 유지하기 위해
7
18
  // 전역 변수로 관리합니다.
8
19
  let i18nInstance = null;
9
- export function getI18nInstance(config) {
20
+ console.log(`[i18n] module loaded. Detected language:`, DETECTED_LANGUAGE);
21
+ export function createAndInitI18nInstance(config) {
10
22
  if (i18nInstance) {
11
23
  return i18nInstance;
12
24
  }
13
- const languageDetector = new LanguageDetector(null, {
14
- lookupCookie: COOKIE_NAME,
15
- lookupQuerystring: QUERYSTRING_NAME,
16
- caches: [], // 사용자의 language 설정을 저장하지 않습니다.
17
- });
18
- const DETECTED_LANGUAGE = languageDetector.detect();
19
- const CONTAINS_KOREAN = typeof DETECTED_LANGUAGE === "string"
20
- ? DETECTED_LANGUAGE.startsWith("ko")
21
- : Array.isArray(DETECTED_LANGUAGE)
22
- ? DETECTED_LANGUAGE.some((lang) => lang.startsWith("ko"))
23
- : false;
24
25
  i18nInstance = i18next
25
26
  .createInstance()
26
27
  .use(languageDetector)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.117.8",
3
+ "version": "1.117.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,