From b0b8f2f875a020c0acc58a159549cea8ae047c39 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 2 Sep 2020 08:57:46 +0100 Subject: [PATCH] utils: support xx_YY format language code Signed-off-by: liushuyu --- tools/import-messages.pl | 6 +++--- tools/split-messages.pl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/import-messages.pl b/tools/import-messages.pl index 4c13a859e..fe23842aa 100644 --- a/tools/import-messages.pl +++ b/tools/import-messages.pl @@ -81,7 +81,7 @@ sub main () } # 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(); } @@ -97,7 +97,7 @@ sub main () my( $lang, $plat, $key ); - if( /^([a-z]{2})\.([^.]+)\.([^:]+):/ ) + if( /(^[a-z]{2}(?:_[A-Z]{2})?)\.([^.]+)\.([^:]+):/ ) { ( $lang, $plat, $key ) = ( $1, $2, $3 ); } @@ -246,7 +246,7 @@ sub parser () while ( <$stream> ) { - if( /^([a-z]{2})\.([^.]+)\.([^:]+):(.*)/ ) + if( /(^[a-z]{2}(?:_[A-Z]{2})?)\.([^.]+)\.([^:]+):(.*)/ ) { my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 ); diff --git a/tools/split-messages.pl b/tools/split-messages.pl index 0504b24c1..1c78fd271 100644 --- a/tools/split-messages.pl +++ b/tools/split-messages.pl @@ -85,7 +85,7 @@ sub main () } # 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(); } @@ -109,7 +109,7 @@ sub main () /^\s*$/ && next; # 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 );