@ihabdevteam/core 0.444.0 → 0.446.0
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/CHANGELOG.md +29 -0
- package/dist/components.cjs.js +183 -183
- package/dist/hooks.cjs.js +5 -5
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +188 -188
- package/dist/ihabdevteam-core.d.ts +16 -1
- package/dist/packages/core/src/components/FolderAddPopup.d.ts +2 -0
- package/dist/packages/core/src/components/FolderAddPopup.js +6 -2
- package/dist/packages/core/src/components/PanelRow.d.ts +6 -0
- package/dist/packages/core/src/components/PanelRow.js +1 -1
- package/dist/packages/core/src/hooks/useMediaQuery.js +8 -0
- package/dist/packages/core/src/i18n/enReadback.json +47 -0
- package/dist/packages/core/src/i18n/index.d.ts +6 -0
- package/dist/packages/core/src/i18n/index.js +71 -2
- package/dist/packages/core/src/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +169 -169
- package/package.json +1 -1
|
@@ -2227,7 +2227,7 @@ export declare function copyText(text: string): Promise<boolean>;
|
|
|
2227
2227
|
*
|
|
2228
2228
|
* 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
|
|
2229
2229
|
*/
|
|
2230
|
-
export declare const CORE_VERSION = "0.
|
|
2230
|
+
export declare const CORE_VERSION = "0.446.0";
|
|
2231
2231
|
|
|
2232
2232
|
/** @public */
|
|
2233
2233
|
declare const coreDefault: Record<string, unknown>;
|
|
@@ -3236,6 +3236,8 @@ export declare function fmtBytes(n: number): string;
|
|
|
3236
3236
|
* · **닫는 길을 넘겨준다**(`onAdd(close)`) — 되면 그때 닫는다. 이름이 틀렸을 때 열린 채로 남아야 고쳐 넣는다.
|
|
3237
3237
|
* · **한글을 조합하는 중의 Enter 로는 안 만든다** — 조합 확정 Enter 는 `TextField.onEnter` 가 가린다.
|
|
3238
3238
|
* · 글 넷은 코어 사전(`folder.add.*` · `common.add`)이다.
|
|
3239
|
+
* · 칸은 **테두리 없는 판 · 줄 하나** 안에 선다(말귀 청 (441), 사장님 지시 2026-11-14 — 칸 하나짜리 창은 모두 이 꼴).
|
|
3240
|
+
* 크기는 판을 따라 48 이다(손으로 안 적는다).
|
|
3239
3241
|
* @public
|
|
3240
3242
|
*/
|
|
3241
3243
|
export declare function FolderAddPopup({ value, onChange, canAdd, error, onAdd, onClose, maxLength }: FolderAddPopupProps): JSX.Element;
|
|
@@ -5138,6 +5140,13 @@ declare type LoadFn = () => Promise<Record<string, {
|
|
|
5138
5140
|
*/
|
|
5139
5141
|
export declare function loadGameLeaderboard(gameKey: string, limit?: number): Promise<LeaderboardRow[] | null>;
|
|
5140
5142
|
|
|
5143
|
+
/**
|
|
5144
|
+
* 그 언어의 코어 사전을 **받아 둔다**(이미 왔으면 바로 끝난다). 언어는 안 바꾼다.
|
|
5145
|
+
* 첫 그리기 전에 영어 사전이 꼭 있어야 하는 앱이 기다린다. `changeLanguage` 는 이것을 스스로 기다린다.
|
|
5146
|
+
* @public
|
|
5147
|
+
*/
|
|
5148
|
+
export declare function loadLocale(code: string): Promise<void>;
|
|
5149
|
+
|
|
5141
5150
|
export declare function loadMyGameRanks(): Promise<Record<string, {
|
|
5142
5151
|
bestScore: number;
|
|
5143
5152
|
rank: number;
|
|
@@ -6086,6 +6095,12 @@ declare type PanelRowInput = Base & {
|
|
|
6086
6095
|
disabled?: boolean;
|
|
6087
6096
|
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
|
|
6088
6097
|
autoComplete?: string;
|
|
6098
|
+
/** 비밀번호 보기/숨기기 단추 — `TextField` 의 `revealable` 로 그대로 간다(말귀 청 (440), 2026-11-14). `type="password"` 일 때만 선다 */
|
|
6099
|
+
revealable?: boolean;
|
|
6100
|
+
/** 첫 글자 대문자(모바일) — `TextField` 의 같은 이름으로 그대로 간다. 안 주면 칸의 쓰임을 보고 TextField 가 정한다 */
|
|
6101
|
+
autoCapitalize?: 'none' | 'off' | 'sentences' | 'words' | 'characters' | 'on';
|
|
6102
|
+
/** 자동 고침(iOS) — `TextField` 의 같은 이름으로 그대로 간다 */
|
|
6103
|
+
autoCorrect?: 'on' | 'off';
|
|
6089
6104
|
/** 칸 아래 안내 한 줄 — `aria-describedby` 로 **칸과 이어진다**(말귀 요청 (60)①, 2026-10-02).
|
|
6090
6105
|
*
|
|
6091
6106
|
* `ReactNode` 다 — 앱이 `<span role="status">` 로 감싸 **값에 따라 바뀌는 안내**를
|
|
@@ -20,6 +20,8 @@ export interface FolderAddPopupProps {
|
|
|
20
20
|
* · **닫는 길을 넘겨준다**(`onAdd(close)`) — 되면 그때 닫는다. 이름이 틀렸을 때 열린 채로 남아야 고쳐 넣는다.
|
|
21
21
|
* · **한글을 조합하는 중의 Enter 로는 안 만든다** — 조합 확정 Enter 는 `TextField.onEnter` 가 가린다.
|
|
22
22
|
* · 글 넷은 코어 사전(`folder.add.*` · `common.add`)이다.
|
|
23
|
+
* · 칸은 **테두리 없는 판 · 줄 하나** 안에 선다(말귀 청 (441), 사장님 지시 2026-11-14 — 칸 하나짜리 창은 모두 이 꼴).
|
|
24
|
+
* 크기는 판을 따라 48 이다(손으로 안 적는다).
|
|
23
25
|
* @public
|
|
24
26
|
*/
|
|
25
27
|
export default function FolderAddPopup({ value, onChange, canAdd, error, onAdd, onClose, maxLength }: FolderAddPopupProps): import("react").JSX.Element;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import ConfirmPopup from './Popup/ConfirmPopup';
|
|
5
|
+
import Panel from './Panel';
|
|
6
|
+
import { PanelRow } from './PanelRow';
|
|
5
7
|
import TextField from './TextField';
|
|
6
8
|
/**
|
|
7
9
|
* **폴더 추가 창**(말귀 청 (438) ㉴ — 말귀 앱에서 옮겨 왔다, 2026-11-14). `FolderHead` · `FolderGrid` · `FolderList` 와 한 벌이다.
|
|
@@ -11,11 +13,13 @@ import TextField from './TextField';
|
|
|
11
13
|
* · **닫는 길을 넘겨준다**(`onAdd(close)`) — 되면 그때 닫는다. 이름이 틀렸을 때 열린 채로 남아야 고쳐 넣는다.
|
|
12
14
|
* · **한글을 조합하는 중의 Enter 로는 안 만든다** — 조합 확정 Enter 는 `TextField.onEnter` 가 가린다.
|
|
13
15
|
* · 글 넷은 코어 사전(`folder.add.*` · `common.add`)이다.
|
|
16
|
+
* · 칸은 **테두리 없는 판 · 줄 하나** 안에 선다(말귀 청 (441), 사장님 지시 2026-11-14 — 칸 하나짜리 창은 모두 이 꼴).
|
|
17
|
+
* 크기는 판을 따라 48 이다(손으로 안 적는다).
|
|
14
18
|
* @public
|
|
15
19
|
*/
|
|
16
20
|
export default function FolderAddPopup({ value, onChange, canAdd, error, onAdd, onClose, maxLength }) {
|
|
17
21
|
const { t } = useTranslation();
|
|
18
22
|
const placeholder = t('folder.add.placeholder', '폴더 이름');
|
|
19
|
-
return (_jsx(ConfirmPopup, { title: t('folder.add.title', '폴더 추가'), subtitle: t('folder.add.sub', '새 폴더 이름을 입력하세요.'), confirmLabel: t('common.add', '추가'), confirmDisabled: !canAdd, closeOnConfirm: false, onConfirm: close => onAdd(close), onClose: onClose, children: _jsx(TextField, { autoFocus: true, value: value, onChange: onChange, placeholder: placeholder, ariaLabel: placeholder, maxLength: maxLength,
|
|
20
|
-
|
|
23
|
+
return (_jsx(ConfirmPopup, { title: t('folder.add.title', '폴더 추가'), subtitle: t('folder.add.sub', '새 폴더 이름을 입력하세요.'), confirmLabel: t('common.add', '추가'), confirmDisabled: !canAdd, closeOnConfirm: false, onConfirm: close => onAdd(close), onClose: onClose, children: _jsx(Panel, { useBorder: false, children: _jsx(PanelRow, { useFullWidth: true, children: _jsx(TextField, { autoFocus: true, value: value, onChange: onChange, placeholder: placeholder, ariaLabel: placeholder, maxLength: maxLength, fullWidth: true, error: error, onEnter: () => { if (canAdd)
|
|
24
|
+
onAdd(onClose); } }) }) }) }));
|
|
21
25
|
}
|
|
@@ -126,6 +126,12 @@ export type PanelRowInput = Base & {
|
|
|
126
126
|
disabled?: boolean;
|
|
127
127
|
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
|
|
128
128
|
autoComplete?: string;
|
|
129
|
+
/** 비밀번호 보기/숨기기 단추 — `TextField` 의 `revealable` 로 그대로 간다(말귀 청 (440), 2026-11-14). `type="password"` 일 때만 선다 */
|
|
130
|
+
revealable?: boolean;
|
|
131
|
+
/** 첫 글자 대문자(모바일) — `TextField` 의 같은 이름으로 그대로 간다. 안 주면 칸의 쓰임을 보고 TextField 가 정한다 */
|
|
132
|
+
autoCapitalize?: 'none' | 'off' | 'sentences' | 'words' | 'characters' | 'on';
|
|
133
|
+
/** 자동 고침(iOS) — `TextField` 의 같은 이름으로 그대로 간다 */
|
|
134
|
+
autoCorrect?: 'on' | 'off';
|
|
129
135
|
/** 칸 아래 안내 한 줄 — `aria-describedby` 로 **칸과 이어진다**(말귀 요청 (60)①, 2026-10-02).
|
|
130
136
|
*
|
|
131
137
|
* `ReactNode` 다 — 앱이 `<span role="status">` 로 감싸 **값에 따라 바뀌는 안내**를
|
|
@@ -111,7 +111,7 @@ export function PanelRow(props) {
|
|
|
111
111
|
}
|
|
112
112
|
else if (variant === 'input') {
|
|
113
113
|
const p = props;
|
|
114
|
-
right = (_jsxs("div", { className: `panel-row__input-wrap${useFullWidth ? ' panel-row__input-wrap--full' : ''}`, children: [_jsx(TextField, { size: rowSize, value: p.value, onChange: p.onChange ?? noop, onKeyDown: p.onKeyDown, onEnter: p.onEnter, placeholder: p.placeholder, ghostText: p.ghostText, inputMode: p.inputMode, readOnly: p.readOnly, disabled: p.disabled, type: p.type, autoComplete: p.autoComplete, maxLength: p.maxLength, showCount: p.showCount, multiline: p.multiline, rows: p.rows, fullWidth: useFullWidth, error: error, ariaLabel: label, required: required, ariaDescribedBy: p.helperText ? helperId : undefined }), p.helperText && _jsx("div", { id: helperId, className: "panel-row__helper caption-1", children: p.helperText })] }));
|
|
114
|
+
right = (_jsxs("div", { className: `panel-row__input-wrap${useFullWidth ? ' panel-row__input-wrap--full' : ''}`, children: [_jsx(TextField, { size: rowSize, value: p.value, onChange: p.onChange ?? noop, onKeyDown: p.onKeyDown, onEnter: p.onEnter, placeholder: p.placeholder, ghostText: p.ghostText, inputMode: p.inputMode, readOnly: p.readOnly, disabled: p.disabled, type: p.type, autoComplete: p.autoComplete, revealable: p.revealable, autoCapitalize: p.autoCapitalize, autoCorrect: p.autoCorrect, maxLength: p.maxLength, showCount: p.showCount, multiline: p.multiline, rows: p.rows, fullWidth: useFullWidth, error: error, ariaLabel: label, required: required, ariaDescribedBy: p.helperText ? helperId : undefined }), p.helperText && _jsx("div", { id: helperId, className: "panel-row__helper caption-1", children: p.helperText })] }));
|
|
115
115
|
}
|
|
116
116
|
else if (variant === 'custom') {
|
|
117
117
|
const p = props;
|
|
@@ -24,11 +24,19 @@ function useMatchesStore(query) {
|
|
|
24
24
|
mql.addEventListener('change', onChange);
|
|
25
25
|
else if (mql.addListener)
|
|
26
26
|
mql.addListener(onChange);
|
|
27
|
+
/* **창 크기 바뀜에도 다시 읽는다**(말귀 실측 2026-11-14) — 폰을 돌렸는데(375 → 812) 판정이 그대로였다. 그때
|
|
28
|
+
`matchMedia(…).matches` 는 이미 false 였으니 값이 아니라 **알림**이 안 온 것이다(기기 흉내에서 change 가 빠지는 때).
|
|
29
|
+
값이 같으면 useSyncExternalStore 가 다시 그리지 않으므로 더 들어도 비용이 없다.
|
|
30
|
+
안-모음: 하는 일이 matchMedia 값 하나를 견주는 것뿐이다 — 같으면 아무것도 안 그린다. */
|
|
31
|
+
window.addEventListener('resize', onChange);
|
|
32
|
+
window.addEventListener('orientationchange', onChange);
|
|
27
33
|
return () => {
|
|
28
34
|
if (mql.removeEventListener)
|
|
29
35
|
mql.removeEventListener('change', onChange);
|
|
30
36
|
else if (mql.removeListener)
|
|
31
37
|
mql.removeListener(onChange);
|
|
38
|
+
window.removeEventListener('resize', onChange);
|
|
39
|
+
window.removeEventListener('orientationchange', onChange);
|
|
32
40
|
};
|
|
33
41
|
}, [query]);
|
|
34
42
|
return React.useSyncExternalStore(subscribe, () => getMatches(query), () => false);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"wordSearch": {
|
|
3
|
+
"filter": {
|
|
4
|
+
"positionAny": "Any",
|
|
5
|
+
"positionHead": "Start",
|
|
6
|
+
"positionMid": "Middle",
|
|
7
|
+
"positionTail": "End",
|
|
8
|
+
"difficulty": "Difficulty",
|
|
9
|
+
"grade": "Grade {{n}}",
|
|
10
|
+
"age": "Age {{n}}",
|
|
11
|
+
"agePlus": "Age {{n}}+",
|
|
12
|
+
"ageRange": "Age {{from}}–{{to}}",
|
|
13
|
+
"difficultyInfoAge": "Age 3–7: the easiest words (grade 1), split by age.",
|
|
14
|
+
"difficultyInfoGrade": "Grades 2–4: harder words, not split by age.",
|
|
15
|
+
"difficultyInfoNone": "None: words with no difficulty assigned.",
|
|
16
|
+
"difficultyInfoBandAge": "{{ages}}: {{grade}} words, split by age.",
|
|
17
|
+
"difficultyInfoBandAgeOne": "{{ages}}: {{grade}} words.",
|
|
18
|
+
"difficultyInfoBandGrade": "{{grade}}: words for {{ages}}.",
|
|
19
|
+
"difficultyInfoBandAgeNamed": "{{ages}}: words split by age.",
|
|
20
|
+
"gradeNone": "None",
|
|
21
|
+
"syllables": "Syllables",
|
|
22
|
+
"syllable": "{{n}} Syll.",
|
|
23
|
+
"syllable5plus": "5+ Syllables",
|
|
24
|
+
"partOfSpeech": "Part of Speech",
|
|
25
|
+
"pos": {
|
|
26
|
+
"noun": "Noun/Numeral",
|
|
27
|
+
"verb": "Verb/Adjective",
|
|
28
|
+
"modifier": "Adverb/Determiner"
|
|
29
|
+
},
|
|
30
|
+
"wordType": "Word Type",
|
|
31
|
+
"field": "Semantic Category",
|
|
32
|
+
"type": {
|
|
33
|
+
"native": "Native Korean",
|
|
34
|
+
"sino": "Sino-Korean",
|
|
35
|
+
"foreign": "Loanword",
|
|
36
|
+
"mixed": "Hybrid"
|
|
37
|
+
},
|
|
38
|
+
"exclude": "Exclude",
|
|
39
|
+
"excludeNoImage": "No Image"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"wordPairs": {
|
|
43
|
+
"filter": {
|
|
44
|
+
"onlyHighUsage": "High-use words only"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -27,6 +27,12 @@ export declare const LOCALE_STORAGE_KEY = "ihab_display_language";
|
|
|
27
27
|
* `test/versionOnEverySubpath.test.ts` 가 갈래마다 이것이 있는지 센다.
|
|
28
28
|
*/
|
|
29
29
|
export { CORE_VERSION } from '../version';
|
|
30
|
+
/**
|
|
31
|
+
* 그 언어의 코어 사전을 **받아 둔다**(이미 왔으면 바로 끝난다). 언어는 안 바꾼다.
|
|
32
|
+
* 첫 그리기 전에 영어 사전이 꼭 있어야 하는 앱이 기다린다. `changeLanguage` 는 이것을 스스로 기다린다.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadLocale(code: string): Promise<void>;
|
|
30
36
|
/** 언어 코드를 localStorage에 저장한다. */
|
|
31
37
|
export declare function saveLocale(code: string): void;
|
|
32
38
|
export default i18n;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import i18n from 'i18next';
|
|
13
13
|
import { initReactI18next } from 'react-i18next';
|
|
14
14
|
import ko from './locales/ko.json' with { type: 'json' };
|
|
15
|
-
import
|
|
15
|
+
import enReadback from './enReadback.json' with { type: 'json' };
|
|
16
16
|
/** 지원 언어 목록 — 새 언어 추가 시 여기에도 추가 */
|
|
17
17
|
export const SUPPORTED_LOCALES = [
|
|
18
18
|
{ code: 'ko', label: '한국어' },
|
|
@@ -31,6 +31,45 @@ export const LOCALE_STORAGE_KEY = 'ihab_display_language';
|
|
|
31
31
|
* `test/versionOnEverySubpath.test.ts` 가 갈래마다 이것이 있는지 센다.
|
|
32
32
|
*/
|
|
33
33
|
export { CORE_VERSION } from '../version';
|
|
34
|
+
/**
|
|
35
|
+
* **영어 사전은 쓸 때 받는다**(말귀 청 (438) ㉳ⓐ, 2026-11-14).
|
|
36
|
+
*
|
|
37
|
+
* 전에는 `en.json`(압축 전 29kB)을 정적으로 들여, 한국어로 보는 사람도 첫 조각에서 영어 사전을 받았다.
|
|
38
|
+
* 이제 한국어(기본 · 대체 언어)만 실어 두고, 다른 언어는 **처음 바꿀 때** 동적 `import()` 로 받는다.
|
|
39
|
+
*
|
|
40
|
+
* · `i18n.changeLanguage('en')` 은 **사전이 다 온 뒤에** 언어를 바꾸고 약속을 푼다 — 바꾸는 사이에 영어 열쇠가
|
|
41
|
+
* 한국어로 새는 틈이 없다. 바꾼 뒤를 보는 쪽은 그 약속을 기다린다(코어 시험은 이미 모두 기다린다).
|
|
42
|
+
* · 저장된 언어가 영어로 **처음 열면** 사전이 오기 전 한 박자는 한국어(대체 언어)로 선다. 그 틈이 싫은 앱은
|
|
43
|
+
* `loadLocale('en')` 을 첫 그리기 전에 기다리거나, `@ihabdevteam/core/i18n/locales/en.json` 을 정적으로
|
|
44
|
+
* 들여 `i18n.addResourceBundle('en', 'translation', en, true, true)` 하면 전과 같다.
|
|
45
|
+
* · 앱 사전을 `addResourceBundle` 로 얹는 길은 그대로다 — 받아 온 코어 사전은 **깊게 합쳐** 앱이 얹은 열쇠를 안 지운다.
|
|
46
|
+
*/
|
|
47
|
+
const LOCALE_LOADERS = {
|
|
48
|
+
en: () => import('./locales/en.json', { with: { type: 'json' } }),
|
|
49
|
+
};
|
|
50
|
+
/* **코어 사전이 왔는가**는 따로 센다 — 창고에 그 언어 묶음이 있는지로 보면 안 된다. 앱이 제 영어 사전을
|
|
51
|
+
`addResourceBundle` 로 먼저 얹으면 묶음은 "있다" 가 되어 코어 영어가 영영 안 온다(i18next 의 backend 길이 그렇게 건너뛴다). */
|
|
52
|
+
const coreLoaded = new Set(['ko']);
|
|
53
|
+
const pending = {};
|
|
54
|
+
/** 'en-US' → 'en' — 받을 사전은 언어 앞마디로 고른다 */
|
|
55
|
+
const baseOf = (code) => code.split('-')[0];
|
|
56
|
+
/**
|
|
57
|
+
* 그 언어의 코어 사전을 **받아 둔다**(이미 왔으면 바로 끝난다). 언어는 안 바꾼다.
|
|
58
|
+
* 첫 그리기 전에 영어 사전이 꼭 있어야 하는 앱이 기다린다. `changeLanguage` 는 이것을 스스로 기다린다.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export function loadLocale(code) {
|
|
62
|
+
const base = baseOf(code);
|
|
63
|
+
const load = LOCALE_LOADERS[base];
|
|
64
|
+
if (!load || coreLoaded.has(base))
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
return (pending[base] ??= load().then((mod) => {
|
|
67
|
+
const bundle = (mod.default ?? mod);
|
|
68
|
+
/* 깊게 합치되 **있는 열쇠는 안 덮는다** — 앱이 먼저 얹은 사전이 이긴다 */
|
|
69
|
+
i18n.addResourceBundle(base, 'translation', bundle, true, false);
|
|
70
|
+
coreLoaded.add(base);
|
|
71
|
+
}, (err) => { pending[base] = undefined; throw err; }));
|
|
72
|
+
}
|
|
34
73
|
/**
|
|
35
74
|
* localStorage에서 저장된 언어 코드를 읽어온다. 없거나 지원하지 않는 코드면 기본값 반환.
|
|
36
75
|
*
|
|
@@ -68,12 +107,20 @@ function syncHtmlLang(code) {
|
|
|
68
107
|
i18n.on('languageChanged', syncHtmlLang);
|
|
69
108
|
// 새로고침 직후 등, i18next 초기화가 비동기로 완료되기 전에도 저장된 언어를 즉시 반영
|
|
70
109
|
syncHtmlLang(getSavedLocale());
|
|
110
|
+
const rawChangeLanguage = (i18n.__ihabRawChangeLanguage ??= i18n.changeLanguage);
|
|
111
|
+
i18n.changeLanguage = rawChangeLanguage;
|
|
71
112
|
i18n
|
|
72
113
|
.use(initReactI18next)
|
|
73
114
|
.init({
|
|
115
|
+
/* 한국어만 싣는다 — 나머지는 바꿀 때 받는다(위 `loadLocale`) */
|
|
74
116
|
resources: {
|
|
75
117
|
ko: { translation: ko },
|
|
76
|
-
|
|
118
|
+
/* **영어 중 '읽어 돌리기' 몫만은 늘 싣는다**(1.5kB). 저장된 필터의 절 · 값 이름을 **어느 언어로 적었든** 읽어
|
|
119
|
+
코드로 돌리는 자리(`wordAttributeFilterCodes` · `useWordTrainingFilter`)가 한국어 화면에서도 영어 이름을 알아야
|
|
120
|
+
한다 — 영어로 보던 사람이 저장한 표를 한국어로 열면 `Semantic Category` · `Grade 1` 이 온다. 이 조각은
|
|
121
|
+
`en.json` 의 같은 자리와 **글자 하나까지 같아야 한다**(`test/lazyEnglishLocale1114` 가 잰다). 열쇠 길:
|
|
122
|
+
`wordSearch.filter.*` · `wordPairs.filter.onlyHighUsage`. */
|
|
123
|
+
en: { translation: enReadback },
|
|
77
124
|
},
|
|
78
125
|
lng: getSavedLocale(), // 새로고침 후에도 저장된 언어 유지
|
|
79
126
|
fallbackLng: DEFAULT_LOCALE,
|
|
@@ -84,4 +131,26 @@ i18n
|
|
|
84
131
|
useSuspense: false,
|
|
85
132
|
},
|
|
86
133
|
});
|
|
134
|
+
/* **언어를 바꾸기 전에 그 사전부터 받는다.** 바꾼 뒤에 받으면 그 사이 한 박자 동안 영어 화면에 한국어가 샌다.
|
|
135
|
+
받기가 실패해도(오프라인 등) 바꾸기는 한다 — 그때는 대체 언어(한국어)로 선다. init 뒤에 감싼다: init 은 제 안에서
|
|
136
|
+
곧바로 언어를 정하므로(사전을 실어 둔 길) 감싸기 전 원래 손으로 돈다. */
|
|
137
|
+
const changeLanguageNow = rawChangeLanguage.bind(i18n);
|
|
138
|
+
/* **마지막으로 청한 언어만 이긴다** — 영어로 바꾸고 사전이 오기 전에 한국어로 되돌리면, 늦게 온 영어가 화면을 도로
|
|
139
|
+
영어로 돌려놓았다. 사전이 왔을 때 그 사이 다른 언어를 청했으면 바꾸지 않는다. */
|
|
140
|
+
let lastRequested;
|
|
141
|
+
i18n.changeLanguage = ((lng, callback) => {
|
|
142
|
+
lastRequested = lng;
|
|
143
|
+
if (!lng || coreLoaded.has(baseOf(lng)) || !LOCALE_LOADERS[baseOf(lng)])
|
|
144
|
+
return changeLanguageNow(lng, callback);
|
|
145
|
+
const go = () => (lastRequested === lng ? changeLanguageNow(lng, callback) : Promise.resolve(i18n.t));
|
|
146
|
+
return loadLocale(lng).then(go, (err) => { console.error(err); return go(); });
|
|
147
|
+
});
|
|
148
|
+
/* 저장된 언어가 영어로 처음 열면 — 사전이 오면 다시 그리게 같은 언어로 한 번 더 알린다 */
|
|
149
|
+
{
|
|
150
|
+
const startLng = i18n.language;
|
|
151
|
+
if (startLng && !coreLoaded.has(baseOf(startLng)) && LOCALE_LOADERS[baseOf(startLng)]) {
|
|
152
|
+
loadLocale(startLng).then(() => { if (i18n.language === startLng && (lastRequested ?? startLng) === startLng)
|
|
153
|
+
void changeLanguageNow(startLng); }, (err) => console.error(err));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
87
156
|
export default i18n;
|