@@ -2,7 +2,7 @@ use anyhow::{anyhow, Ok, Result};
22use lazy_static:: lazy_static;
33use regex:: { Captures , Match , Regex } ;
44use std:: { collections:: HashMap , io:: Write , path:: Path } ;
5-
5+ use std :: borrow :: Cow ;
66use std:: fs;
77
88use crate :: parse:: { File , Key , LocalizedString , PluralValue , Section , StringValue } ;
@@ -50,9 +50,7 @@ impl GenResult {
5050 let lang = LANG_WITH_REGION_RE . replace_all ( & locale. value , |caps : & Captures | {
5151 format ! ( "-r{}" , caps. get( 1 ) . unwrap( ) . as_str( ) )
5252 } ) ;
53- if !locale_code_supported_in_android ( & lang) {
54- continue ;
55- }
53+ let lang = update_special_locales ( & lang) ;
5654
5755 let subpath = dir. as_ref ( ) . join ( format ! ( "values-{}" , lang) ) ;
5856 if !subpath. is_dir ( ) {
@@ -92,9 +90,16 @@ impl GenResult {
9290 }
9391}
9492
95- fn locale_code_supported_in_android ( code : & str ) -> bool {
96- // https://stackoverflow.com/questions/17275697/is-there-any-need-to-prepare-values-zh-and-values-zh-rhk/17276279
97- return code != "zh-rHans" && code != "zh-rHant" && code != "zh-rPinyin" ;
93+ // https://stackoverflow.com/questions/17275697/is-there-any-need-to-prepare-values-zh-and-values-zh-rhk/17276279
94+ fn update_special_locales ( code : & str ) -> String {
95+ return match code {
96+ "zh-rHans" | "zh-rHant" | "zh-rPinyin" => {
97+ "zh-rCN" . to_string ( )
98+ }
99+ & _ => {
100+ code. to_string ( )
101+ }
102+ } ;
98103}
99104
100105pub fn generate ( source : & File ) -> Result < GenResult > {
0 commit comments