fix(i18n): 繁中開屏 consent 文案不生效 - 寫死繁中文案、清理腳本、文件
- splash: 繁中 consent 使用元件內 ZH_TW_CONSENT,避免 bundle 快取 - splash: 使用 isTraditionalChineseLocaleTag 判斷繁中 - i18n: 註解與 __DEV__ debug log - package: clean:cache, start:clean, ios:clean, clean:ios-build - ALL_COPY: 故障排除與 consent 只改 zh-TW.json 說明 - spec_kit: Splash Consent overflow 記錄排查結論 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
## 应用文案总表(请在此文件对应的 JSON 中修改)
|
||||
## 應用文案總表(請在對應 JSON 中修改)
|
||||
|
||||
**单一文案源文件**:`client/src/i18n/locales/all.json`
|
||||
### 語言與檔案對應(單一來源,避免多檔覆蓋)
|
||||
|
||||
- **English**:`all.json` 的 `en`
|
||||
- **繁体中文**:`all.json` 的 `zh-TW`
|
||||
| 語言 | 實際使用的檔案 | 說明 |
|
||||
|------------|-----------------------------|------|
|
||||
| **英文** | `locales/all.json` 的 `en` | 只改 all.json 的 `en` 區塊 |
|
||||
| **繁體中文** | `locales/zh-TW.json` | **唯一來源**,Onboarding / 開屏 consent 等繁中文案只改此檔 |
|
||||
|
||||
> 说明:项目运行时只读取 `all.json`;请不要再改 `locales/en.json`、`locales/zh-TW.json`(它们已不再作为运行时数据源)。
|
||||
- 運行時 **繁中(zh-TW)只讀取 `zh-TW.json`**,不會讀取 `all.json` 的 zh-TW 區塊。
|
||||
- 修改 JSON 後需**重新載入 App**(模擬器 `Cmd+R`)或重啟 Metro(必要時加 `--clear`)才會看到新文案。
|
||||
- **若修改 zh-TW.json 後開屏 consent 仍顯示舊文案**:請執行 `npm run clean:cache`,再以 `npm run start:clean` 啟動 Metro(或先刪除模擬器上的 App 再執行 `npm run ios:clean`),確保吃到最新 bundle。
|
||||
|
||||
### 快速索引(高频文案)
|
||||
### 快速索引(高頻文案)
|
||||
|
||||
- **開屏 / 協議**:`consent.*`(**繁中只改 zh-TW.json**:`consent.title`、`consent.subtitle`、`consent.subtitleSecondary`、agree, privacy, terms, notice…)
|
||||
- **Onboarding 問卷**:`onboardingSurvey.steps.*`(name.title, status.title, status.options.* …)
|
||||
- **Onboarding 招呼語**:`onboardingSurvey.greeting`(例:Hi {{name}},)
|
||||
- **Home**:`home.*`
|
||||
- **Push 提示**:`push.*`
|
||||
- **主题**:`theme.*`
|
||||
- **我的/Profile**:`profile.*`
|
||||
- **主題**:`theme.*`
|
||||
- **我的 / Profile**:`profile.*`
|
||||
- **收藏**:`favorites.*`
|
||||
- **设置**:`settings.*`
|
||||
- **Onboarding(问卷)**:`onboardingSurvey.steps.*`
|
||||
- **Onboarding(兴趣)**:`intent.*`
|
||||
- **設定**:`settings.*`
|
||||
- **Mock 文案**:`mock.*`
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,12 @@ import { initReactI18next } from 'react-i18next';
|
||||
import { isTraditionalChineseLocaleTag } from './locale';
|
||||
|
||||
// 用 require 避免 TS 的 json module 配置差异导致无法编译
|
||||
// 繁中(zh-TW)唯一來源:locales/zh-TW.json,修改 Onboarding/開屏等繁中文案請只改該檔案
|
||||
// 本 App 未載入 zh-CN.json;若看到類似「你本就完美」「一切都会变好」等簡中 consent 文案,為舊 bundle 快取導致,請執行 clean:cache + start:clean 或卸載 App 重裝。
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const all = require('./locales/all.json') as { en: Record<string, unknown>; 'zh-TW': Record<string, unknown> };
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const zhTW = require('./locales/zh-TW.json') as Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* 语言码约定:
|
||||
@@ -81,7 +85,8 @@ export async function initI18n(): Promise<void> {
|
||||
|
||||
await i18n.use(initReactI18next).init({
|
||||
resources: {
|
||||
'zh-TW': { translation: all['zh-TW'] as any },
|
||||
// 繁中唯一來源:zh-TW.json(all.json 的 zh-TW 區塊不會被載入)
|
||||
'zh-TW': { translation: zhTW },
|
||||
en: { translation: all.en as any },
|
||||
},
|
||||
lng: initialLang,
|
||||
@@ -91,6 +96,18 @@ export async function initI18n(): Promise<void> {
|
||||
escapeValue: false,
|
||||
},
|
||||
});
|
||||
|
||||
// 臨時 debug:確認實際使用的 language 與 consent.title 值(方便驗證繁中來自 zh-TW.json)
|
||||
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
||||
const consentTitle = i18n.t('consent.title');
|
||||
console.log(
|
||||
'[i18n] 已初始化 language=',
|
||||
i18n.language,
|
||||
'| consent.title=',
|
||||
consentTitle,
|
||||
'| 繁中來源=zh-TW.json,英文來源=all.json 的 en 區塊'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,6 +146,7 @@
|
||||
"consent": {
|
||||
"title": "Hey mama.",
|
||||
"subtitle": "You’re doing okay\nright now.",
|
||||
"subtitleSecondary": "",
|
||||
"agree": "Agree & Continue",
|
||||
"privacy": "Privacy Policy",
|
||||
"terms": "Terms of Use",
|
||||
@@ -196,19 +197,19 @@
|
||||
"q4Desc": "你可以直接跳過,我們會在之後繼續陪你。"
|
||||
},
|
||||
"onboardingSurvey": {
|
||||
"greeting": "{{name}},你好",
|
||||
"greeting": "Hi {{name}},",
|
||||
"steps": {
|
||||
"name": { "title": "我可以怎麼稱呼你?", "placeholder": "媽媽" },
|
||||
"name": { "title": "怎麼稱呼你呢?", "placeholder": "媽媽" },
|
||||
"status": {
|
||||
"title": "媽媽的狀態?",
|
||||
"title": "你現在正處在哪個階段呢?",
|
||||
"options": {
|
||||
"pregnant": "懷孕中/準備成為媽媽",
|
||||
"pregnant": "懷孕中/正在準備迎接寶寶",
|
||||
"has_kids": "已經有孩子",
|
||||
"no_fill": "不想填寫"
|
||||
"no_fill": "我暫時不想說"
|
||||
}
|
||||
},
|
||||
"emotion": {
|
||||
"title": "當下情緒狀態?",
|
||||
"title": "今天的你,還好嗎?",
|
||||
"options": {
|
||||
"happy": "愉悅、滿足",
|
||||
"calm": "平靜、安穩",
|
||||
@@ -315,8 +316,9 @@
|
||||
"widgetDesc": "把溫柔提醒放到桌面上:長按主畫面 → 點「+」 → 搜尋「正念」 → 添加你喜歡的尺寸。"
|
||||
},
|
||||
"consent": {
|
||||
"title": "你很完美。",
|
||||
"subtitle": "一切\n都會更好。",
|
||||
"title": "我們知道,",
|
||||
"subtitle": "當媽媽很不容易。",
|
||||
"subtitleSecondary": "這裡給你一些溫柔的肯定與提醒",
|
||||
"agree": "同意並繼續",
|
||||
"privacy": "隱私協議",
|
||||
"terms": "用戶使用協議",
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
"common": {
|
||||
"ok": "確定",
|
||||
"cancel": "取消",
|
||||
"back": "返回"
|
||||
"back": "返回",
|
||||
"error": "錯誤",
|
||||
"notice": "提示",
|
||||
"openLinkError": "無法打開鏈接",
|
||||
"close": "關閉"
|
||||
},
|
||||
"onboarding": {
|
||||
"title": "歡迎",
|
||||
@@ -19,6 +23,64 @@
|
||||
"q4Title": "給自己一句溫柔的話",
|
||||
"q4Desc": "你可以直接跳過,我們會在之後繼續陪你。"
|
||||
},
|
||||
"onboardingSurvey": {
|
||||
"greeting": "Hi {{name}},",
|
||||
"steps": {
|
||||
"name": {
|
||||
"title": "怎麼稱呼你呢?",
|
||||
"placeholder": "媽媽"
|
||||
},
|
||||
"status": {
|
||||
"title": "你現在正處在哪個階段呢?",
|
||||
"options": {
|
||||
"pregnant": "懷孕中/正在準備迎接寶寶",
|
||||
"has_kids": "已經有孩子",
|
||||
"no_fill": "我暫時不想說"
|
||||
}
|
||||
},
|
||||
"emotion": {
|
||||
"title": "今天的你,還好嗎?",
|
||||
"options": {
|
||||
"happy": "愉悅、滿足",
|
||||
"calm": "平靜、安穩",
|
||||
"okay": "還可以、普通",
|
||||
"tired": "疲累、沒什麼力氣",
|
||||
"stressed": "被壓得有點喘不過氣",
|
||||
"low": "情緒低落"
|
||||
}
|
||||
},
|
||||
"influence": {
|
||||
"title": "是什麼影響了你最近的感受?",
|
||||
"options": {
|
||||
"family": "家庭與孩子",
|
||||
"work": "工作或學習",
|
||||
"relationship": "親密關係",
|
||||
"friends": "朋友與人際",
|
||||
"health": "身心健康"
|
||||
}
|
||||
},
|
||||
"support": {
|
||||
"title": "最需要什麼支持?",
|
||||
"options": {
|
||||
"emotional": "情緒支持",
|
||||
"parenting": "育兒壓力",
|
||||
"self_worth": "自我價值",
|
||||
"anxiety": "焦慮舒緩",
|
||||
"balance": "休息與平衡"
|
||||
}
|
||||
},
|
||||
"reminder": {
|
||||
"title": "你希望一天收到幾次肯定語?"
|
||||
}
|
||||
}
|
||||
},
|
||||
"intent": {
|
||||
"title": "你希望得到什麼幫助?",
|
||||
"love": "愛情",
|
||||
"life": "生活",
|
||||
"travel": "旅遊",
|
||||
"work": "職場"
|
||||
},
|
||||
"push": {
|
||||
"title": "通知",
|
||||
"cardTitle": "開啟溫柔提醒",
|
||||
@@ -41,7 +103,8 @@
|
||||
"theme": {
|
||||
"title": "主題",
|
||||
"scenery": "風景",
|
||||
"color": "顏色"
|
||||
"color": "顏色",
|
||||
"suixin": "隨心"
|
||||
},
|
||||
"profile": {
|
||||
"title": "我的",
|
||||
@@ -66,12 +129,16 @@
|
||||
"widget": {
|
||||
"lockScreen": "鎖屏小工具",
|
||||
"homeScreen": "桌面小工具",
|
||||
"howToTitle": "如何添加小工具",
|
||||
"howToDesc1": "長按主畫面空白處進入編輯,點左上角「+」新增小工具。",
|
||||
"howToDesc2": "搜尋「正念」,選擇喜歡的尺寸,點「加入小工具」。",
|
||||
"previewDate": "1月29日週四 · 已至臘月十一",
|
||||
"previewQuote": "我也對現在的自己感到滿意,即使我仍在努力成為想成為的人。"
|
||||
},
|
||||
"favorites": {
|
||||
"title": "收藏夾",
|
||||
"empty": "這裡還沒有收藏內容。"
|
||||
"empty": "這裡還沒有收藏內容。",
|
||||
"unknownText": "這條文案暫時無法顯示。"
|
||||
},
|
||||
"settings": {
|
||||
"title": "設定",
|
||||
@@ -81,9 +148,30 @@
|
||||
"widgetDesc": "把溫柔提醒放到桌面上:長按主畫面 → 點「+」 → 搜尋「正念」 → 添加你喜歡的尺寸。"
|
||||
},
|
||||
"consent": {
|
||||
"title": "我們知道,",
|
||||
"subtitle": "當媽媽很不容易。",
|
||||
"subtitleSecondary": "這裡給你一些溫柔的肯定與提醒",
|
||||
"agree": "同意並繼續",
|
||||
"privacy": "隱私協議",
|
||||
"terms": "用戶使用協議"
|
||||
"terms": "用戶使用協議",
|
||||
"notice": "繼續使用即代表你同意《隱私協議》與《用戶使用協議》。",
|
||||
"noticeRich": "繼續使用即代表你同意<privacy>《{{privacyLabel}}》{{privacySuffix}}</privacy>與<terms>《{{termsLabel}}》{{termsSuffix}}</terms>。",
|
||||
"linkUnavailable": "協議鏈接載入失敗,請檢查網路後重試。",
|
||||
"linkUnavailableDev": "協議鏈接載入失敗,請檢查網路或 API_BASE_URL 設定:{{baseUrl}}",
|
||||
"linkLoadingSuffix": "(載入中…)"
|
||||
},
|
||||
"permissions": {
|
||||
"notificationsDenied": "系統權限已被拒絕,請前往手機設定開啟通知。"
|
||||
},
|
||||
"language": {
|
||||
"zhTW": "繁體中文",
|
||||
"en": "English"
|
||||
},
|
||||
"mock": {
|
||||
"c1": "你已經很努力了,今天也值得被溫柔對待。",
|
||||
"c2": "深呼吸三次,把注意力帶回當下。",
|
||||
"c3": "允許自己慢一點,情緒會像雲一樣飄過。",
|
||||
"c4": "你不需要完美,你已經足夠好。",
|
||||
"c5": "把手放在心口,對自己說一句:辛苦了。"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user