@@ -4,6 +4,7 @@ mod german;
44mod japanese;
55mod korean;
66mod spanish;
7+ mod traditional_chinese;
78
89use windows:: core:: PWSTR ;
910use windows:: Win32 :: Globalization :: {
@@ -19,16 +20,18 @@ pub enum LanguageId {
1920 German ,
2021 Japanese ,
2122 Korean ,
23+ TraditionalChinese ,
2224}
2325
2426impl LanguageId {
25- pub const ALL : [ LanguageId ; 6 ] = [
27+ pub const ALL : [ LanguageId ; 7 ] = [
2628 LanguageId :: English ,
2729 LanguageId :: Spanish ,
2830 LanguageId :: French ,
2931 LanguageId :: German ,
3032 LanguageId :: Japanese ,
3133 LanguageId :: Korean ,
34+ LanguageId :: TraditionalChinese ,
3235 ] ;
3336
3437 pub fn code ( self ) -> & ' static str {
@@ -39,6 +42,7 @@ impl LanguageId {
3942 Self :: German => "de" ,
4043 Self :: Japanese => "ja" ,
4144 Self :: Korean => "ko" ,
45+ Self :: TraditionalChinese => "zh-TW" ,
4246 }
4347 }
4448
@@ -50,6 +54,7 @@ impl LanguageId {
5054 Self :: German => "Deutsch" ,
5155 Self :: Japanese => "日本語" ,
5256 Self :: Korean => "한국어" ,
57+ Self :: TraditionalChinese => "繁體中文" ,
5358 }
5459 }
5560
@@ -61,6 +66,7 @@ impl LanguageId {
6166 Self :: German => german:: STRINGS ,
6267 Self :: Japanese => japanese:: STRINGS ,
6368 Self :: Korean => korean:: STRINGS ,
69+ Self :: TraditionalChinese => traditional_chinese:: STRINGS ,
6470 }
6571 }
6672
@@ -72,6 +78,7 @@ impl LanguageId {
7278 Self :: German => german:: UPDATE_VIA_WINGET_LABEL ,
7379 Self :: Japanese => japanese:: UPDATE_VIA_WINGET_LABEL ,
7480 Self :: Korean => korean:: UPDATE_VIA_WINGET_LABEL ,
81+ Self :: TraditionalChinese => traditional_chinese:: UPDATE_VIA_WINGET_LABEL ,
7582 }
7683 }
7784
@@ -81,13 +88,24 @@ impl LanguageId {
8188 return None ;
8289 }
8390
84- match normalized. split ( '-' ) . next ( ) . unwrap_or_default ( ) {
91+ let prefix = normalized. split ( '-' ) . next ( ) . unwrap_or_default ( ) ;
92+ match prefix {
8593 "en" => Some ( Self :: English ) ,
8694 "es" => Some ( Self :: Spanish ) ,
8795 "fr" => Some ( Self :: French ) ,
8896 "de" => Some ( Self :: German ) ,
8997 "ja" => Some ( Self :: Japanese ) ,
9098 "ko" => Some ( Self :: Korean ) ,
99+ "zh" => {
100+ if normalized. contains ( "tw" )
101+ || normalized. contains ( "hk" )
102+ || normalized. contains ( "hant" )
103+ {
104+ Some ( Self :: TraditionalChinese )
105+ } else {
106+ None
107+ }
108+ }
91109 _ => None ,
92110 }
93111 }
0 commit comments