@@ -20,7 +20,8 @@ const ILOT_INSTALL: u32 = 0x00000000;
2020// const ILOT_UNINSTALL: u32 = 0x00000001;
2121
2222const CHEWING_TSF_CLSID : GUID = GUID :: from_u128 ( 0x13F2EF08_575C_4D8C_88E0_F67BB8052B84 ) ;
23- const CHEWING_PROFILE_GUID : GUID = GUID :: from_u128 ( 0xCE45F71D_CE79_41D1_967D_640B65A380E3 ) ;
23+ const CHEWING_ZH_TW_PROFILE_GUID : GUID = GUID :: from_u128 ( 0xCE45F71D_CE79_41D1_967D_640B65A380E3 ) ;
24+ const CHEWING_ZH_CN_PROFILE_GUID : GUID = GUID :: from_u128 ( 0x9063E7CC_225E_4CEA_B7A1_2B0FB12A75CF ) ;
2425const CHEWING_TIP_DESC : PCWSTR =
2526 w ! ( "0x0404:{13F2EF08-575C-4D8C-88E0-F67BB8052B84}{CE45F71D-CE79-41D1-967D-640B65A380E3}" ) ;
2627
@@ -38,17 +39,17 @@ fn register(icon_path: String) -> Result<()> {
3839 let input_processor_profile_mgr: ITfInputProcessorProfileMgr =
3940 CoCreateInstance ( & CLSID_TF_InputProcessorProfiles , None , CLSCTX_INPROC_SERVER ) ?;
4041
41- let mut lcid = LocaleNameToLCID ( w ! ( "zh-Hant-TW" ) , 0 ) ;
42- if lcid == 0 {
43- lcid = LocaleNameToLCID ( w ! ( "zh-TW" ) , 0 ) ;
44- }
45-
4642 let pw_icon_path = icon_path. encode_utf16 ( ) . collect :: < Vec < _ > > ( ) ;
4743
44+ // Register for zh_TW
45+ let mut lcid = LocaleNameToLCID ( w ! ( "zh-TW" ) , 0 ) ;
46+ if matches ! ( lcid, 0 | 0x0C00 | 0x1000 ) {
47+ lcid = 0x404 ;
48+ }
4849 input_processor_profile_mgr. RegisterProfile (
4950 & CHEWING_TSF_CLSID ,
5051 lcid as u16 ,
51- & CHEWING_PROFILE_GUID ,
52+ & CHEWING_ZH_TW_PROFILE_GUID ,
5253 w ! ( "新酷音輸入法" ) . as_wide ( ) ,
5354 & pw_icon_path,
5455 0 ,
@@ -57,6 +58,23 @@ fn register(icon_path: String) -> Result<()> {
5758 false ,
5859 0 ,
5960 ) ?;
61+ // Register for zh_CN
62+ let mut lcid = LocaleNameToLCID ( w ! ( "zh-CN" ) , 0 ) ;
63+ if matches ! ( lcid, 0 | 0x0C00 | 0x1000 ) {
64+ lcid = 0x804 ;
65+ }
66+ input_processor_profile_mgr. RegisterProfile (
67+ & CHEWING_TSF_CLSID ,
68+ lcid as u16 ,
69+ & CHEWING_ZH_CN_PROFILE_GUID ,
70+ w ! ( "新酷音输入法" ) . as_wide ( ) ,
71+ & pw_icon_path,
72+ 0 ,
73+ HKL :: default ( ) ,
74+ 0 ,
75+ false ,
76+ 0 ,
77+ ) ?;
6078
6179 let category_manager: ITfCategoryMgr =
6280 CoCreateInstance ( & CLSID_TF_CategoryMgr , None , CLSCTX_INPROC_SERVER ) ?;
@@ -92,15 +110,26 @@ fn unregister() -> Result<()> {
92110 }
93111 }
94112
95- let mut lcid = LocaleNameToLCID ( w ! ( "zh-Hant-TW" ) , 0 ) ;
96- if lcid == 0 {
97- lcid = LocaleNameToLCID ( w ! ( "zh-TW" ) , 0 ) ;
113+ // Unregister zh_TW profile
114+ let mut lcid = LocaleNameToLCID ( w ! ( "zh-TW" ) , 0 ) ;
115+ if matches ! ( lcid, 0 | 0x0C00 | 0x1000 ) {
116+ lcid = 0x404 ;
117+ }
118+ input_processor_profile_mgr. UnregisterProfile (
119+ & CHEWING_TSF_CLSID ,
120+ lcid as u16 ,
121+ & CHEWING_ZH_TW_PROFILE_GUID ,
122+ 0 ,
123+ ) ?;
124+ // Unregister zh_CN profile
125+ let mut lcid = LocaleNameToLCID ( w ! ( "zh-CN" ) , 0 ) ;
126+ if matches ! ( lcid, 0 | 0x0C00 | 0x1000 ) {
127+ lcid = 0x804 ;
98128 }
99-
100129 input_processor_profile_mgr. UnregisterProfile (
101130 & CHEWING_TSF_CLSID ,
102131 lcid as u16 ,
103- & CHEWING_PROFILE_GUID ,
132+ & CHEWING_ZH_CN_PROFILE_GUID ,
104133 0 ,
105134 ) ?;
106135 }
0 commit comments