utils: support xx_YY format language code

Signed-off-by: liushuyu <liushuyu@aosc.io>
This commit is contained in:
liushuyu 2020-09-02 08:57:46 +01:00 committed by Vincent Sanders
parent 1ea47f9caf
commit b0b8f2f875
2 changed files with 5 additions and 5 deletions

View File

@ -81,7 +81,7 @@ sub main ()
} }
# double check the options are sane (and we weren't asked for the help) # double check the options are sane (and we weren't asked for the help)
if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}$/ ) if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}(?:_[A-Z]{2})?$/ )
{ {
usage(); usage();
} }
@ -97,7 +97,7 @@ sub main ()
my( $lang, $plat, $key ); my( $lang, $plat, $key );
if( /^([a-z]{2})\.([^.]+)\.([^:]+):/ ) if( /(^[a-z]{2}(?:_[A-Z]{2})?)\.([^.]+)\.([^:]+):/ )
{ {
( $lang, $plat, $key ) = ( $1, $2, $3 ); ( $lang, $plat, $key ) = ( $1, $2, $3 );
} }
@ -246,7 +246,7 @@ sub parser ()
while ( <$stream> ) while ( <$stream> )
{ {
if( /^([a-z]{2})\.([^.]+)\.([^:]+):(.*)/ ) if( /(^[a-z]{2}(?:_[A-Z]{2})?)\.([^.]+)\.([^:]+):(.*)/ )
{ {
my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 ); my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 );

View File

@ -85,7 +85,7 @@ sub main ()
} }
# double check the options are sane (and we weren't asked for the help) # double check the options are sane (and we weren't asked for the help)
if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}$/ || $opt{dlang} !~ /^[a-z]{2}$/ ) if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}(?:_[A-Z]{2})?$/ || $opt{dlang} !~ /^[a-z]{2}(?:_[A-Z]{2})?$/ )
{ {
usage(); usage();
} }
@ -109,7 +109,7 @@ sub main ()
/^\s*$/ && next; /^\s*$/ && next;
# only parsing things that look like message lines: # only parsing things that look like message lines:
if( /^([a-z]{2}).([^.]+).([^:]+):(.*)/ ) if( /^([a-z]{2}(?:_[A-Z]{2})?).([^.]+).([^:]+):(.*)/ )
{ {
my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 ); my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 );