Skip to content

Commit 1637e3f

Browse files
committed
chore(i18n): 移除繁体中文支持
- 删除 lib/l10n/translations/zh_tw.dart - app_localizations.dart:去掉 zh_TW import、_localizedValues 条目、 isSupported 不再 fallback Hant;supportedLocales 只保留 en + zh; localeDisplayNames / getLocaleKey / parseLocaleKey 全部简化 - settings/widgets/language_section.dart:allLanguages 去掉 zh_TW 选项 - utils/locale_utils.dart:注释里去掉 zh_TW 繁体中文翻译文件 zh_tw.dart 内容不全且过时(很多 key 用 fallback en), 继续维护性价比低;现在 zh.dart 已经够用,需要时未来还可恢复。
1 parent e002f87 commit 1637e3f

4 files changed

Lines changed: 3 additions & 141 deletions

File tree

lib/l10n/app_localizations.dart

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22

33
import 'translations/en.dart' as t_en;
44
import 'translations/zh.dart' as t_zh;
5-
import 'translations/zh_tw.dart' as t_zh_tw;
65

76
/// App translations for all supported languages
87
class AppLocalizations {
@@ -19,14 +18,10 @@ class AppLocalizations {
1918
static final Map<String, Map<String, String>> _localizedValues = {
2019
'en': t_en.en,
2120
'zh': t_zh.zh,
22-
'zh_TW': t_zh_tw.zhTW,
2321
};
2422

2523
String get(String key) {
26-
String langCode = locale.languageCode;
27-
if (locale.scriptCode == 'Hant' || locale.countryCode == 'TW' || locale.countryCode == 'HK') {
28-
langCode = 'zh_TW';
29-
}
24+
final langCode = locale.languageCode;
3025
return _localizedValues[langCode]?[key] ?? _localizedValues['en']?[key] ?? key;
3126
}
3227

@@ -65,31 +60,20 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
6560
const supportedLocales = [
6661
Locale('en'),
6762
Locale('zh'),
68-
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
6963
];
7064

71-
/// Language display names (legacy, use allLanguages in settings_screen.dart)
65+
/// Language display names
7266
const localeDisplayNames = {
7367
'en': 'English',
7468
'zh': '简体中文',
75-
'zh_TW': '繁體中文',
7669
};
7770

7871
/// Get locale key for storage
7972
String getLocaleKey(Locale locale) {
80-
if (locale.languageCode == 'zh') {
81-
if (locale.scriptCode == 'Hant' || locale.countryCode == 'TW' || locale.countryCode == 'HK') {
82-
return 'zh_TW';
83-
}
84-
return 'zh';
85-
}
8673
return locale.languageCode;
8774
}
8875

8976
/// Parse locale from key
9077
Locale parseLocaleKey(String key) {
91-
if (key == 'zh_TW') {
92-
return const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant');
93-
}
9478
return Locale(key);
9579
}

lib/l10n/translations/zh_tw.dart

Lines changed: 0 additions & 117 deletions
This file was deleted.

lib/screens/settings/widgets/language_section.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ class LanguageSection extends ConsumerWidget {
1414
static const allLanguages = {
1515
'en': {'flag': '🇺🇸', 'native': 'English', 'english': 'English'},
1616
'zh': {'flag': '🇨🇳', 'native': '简体中文', 'english': 'Simplified Chinese'},
17-
'zh_TW': {
18-
'flag': '🇹🇼',
19-
'native': '繁體中文',
20-
'english': 'Traditional Chinese'
21-
},
2217
};
2318

2419
@override

lib/utils/locale_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bool isZhLocale(BuildContext context) {
55
return Localizations.localeOf(context).languageCode == 'zh';
66
}
77

8-
/// Get locale key for comparison (e.g., 'en', 'zh', 'zh_TW')
8+
/// Get locale key for comparison (e.g., 'en', 'zh')
99
String? getLocaleKey(Locale? locale) {
1010
if (locale == null) return null;
1111
if (locale.countryCode != null && locale.countryCode!.isNotEmpty) {

0 commit comments

Comments
 (0)