!268 组合度量衡格式化

Merge pull request !268 from W.J/master
This commit is contained in:
openharmony_ci 2024-11-05 09:49:29 +00:00 committed by Gitee
commit 9e630e5eb9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 410 additions and 5 deletions

View File

@ -60,7 +60,10 @@ static const int32_t gOffsets[] = {
450, 450,
454, 454,
456, 456,
490 490,
/* IASH19 Add 10 measure units 20241104 begin */
500
/* IASH19 Add 10 measure units 20241104 end */
}; };
static const int32_t kCurrencyOffset = 5; static const int32_t kCurrencyOffset = 5;
@ -89,7 +92,10 @@ static const char * const gTypes[] = {
"speed", "speed",
"temperature", "temperature",
"torque", "torque",
"volume" "volume",
/* IASH19 Add 10 measure units 20241104 begin */
"zohos"
/* IASH19 Add 10 measure units 20241104 end */
}; };
// Must be grouped by type and sorted alphabetically within each type. // Must be grouped by type and sorted alphabetically within each type.
@ -583,7 +589,19 @@ static const char * const gSubTypes[] = {
"quart", "quart",
"quart-imperial", "quart-imperial",
"tablespoon", "tablespoon",
"teaspoon" "teaspoon",
/* IASH19 Add 10 measure units 20241104 begin */
"beat-per-minute",
"body-weight-per-second",
"breath-per-minute",
"foot-per-hour",
"jump-rope-per-minute",
"meter-per-hour",
"milliliter-per-minute-per-kilogram",
"rotation-per-minute",
"step-per-minute",
"stroke-per-minute"
/* IASH19 Add 10 measure units 20241104 end */
}; };
// Shortcuts to the base unit in order to make the default constructor fast // Shortcuts to the base unit in order to make the default constructor fast

View File

@ -1,3 +1,15 @@
{ {
"strategy": "subtractive" "strategy": "subtractive",
"fileReplacements": {
"directory": "$FILTERS",
"replacements": [
"unit/bo.txt",
"unit/en_001.txt",
"unit/root.txt",
"unit/ug.txt",
"unit/zh.txt",
"unit/zh_Hant.txt",
"unit/zh_Hant_HK.txt"
]
}
} }

View File

@ -0,0 +1,42 @@
zohos{
beat-per-minute{
dnam{"སྐར་མ་རེར་ཐེངས་"}
other{"སྐར་མ་རེར་ཐེངས་ {0}"}
}
body-weight-per-second{
dnam{"BW/s"}
other{"{0} BW/s"}
}
breath-per-minute{
dnam{"སྐར་མ་རེར་ཐེངས་"}
other{"སྐར་མ་རེར་ཐེངས་ {0}"}
}
foot-per-hour{
dnam{"ft/h"}
other{"{0} ft/h"}
}
jump-rope-per-minute{
dnam{"སྐར་མ་རེར་"}
other{"སྐར་མ་རེར་ {0}"}
}
meter-per-hour{
dnam{"m/h"}
other{"{0} m/h"}
}
milliliter-per-minute-per-kilogram{
dnam{"ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
dnam{"སྐར་མ་རེར་སྐོར་བ་"}
other{"སྐར་མ་རེར་སྐོར་བ་ {0}"}
}
step-per-minute{
dnam{"སྐར་མ་རེར་གོམ་པ་"}
other{"སྐར་མ་རེར་གོམ་པ་ {0}"}
}
stroke-per-minute{
dnam{"སྐར་མ་རེར་ཐེངས་"}
other{"སྐར་མ་རེར་ཐེངས་ {0}"}
}
}

View File

@ -0,0 +1,7 @@
zohos{
jump-rope-per-minute{
dnam{"skip/minute"}
one{"{0} skip/minute"}
other{"{0} skips/minute"}
}
}

View File

@ -0,0 +1,45 @@
zohos{
beat-per-minute{
dnam{"bpm"}
other{"{0} bpm"}
}
body-weight-per-second{
dnam{"BW/s"}
other{"{0} BW/s"}
}
breath-per-minute{
dnam{"brpm"}
other{"{0} brpm"}
}
foot-per-hour{
dnam{"ft/h"}
other{"{0} ft/h"}
}
jump-rope-per-minute{
dnam{"jump/minute"}
one{"{0} jump/minute"}
other{"{0} jumps/minute"}
}
meter-per-hour{
dnam{"m/h"}
other{"{0} m/h"}
}
milliliter-per-minute-per-kilogram{
dnam{"ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
dnam{"rpm"}
other{"{0} rpm"}
}
step-per-minute{
dnam{"step/min"}
one{"{0} step/min"}
other{"{0} steps/min"}
}
stroke-per-minute{
dnam{"stroke/min"}
one{"{0} stroke/min"}
other{"{0} strokes/min"}
}
}

View File

@ -0,0 +1,42 @@
zohos{
beat-per-minute{
one{"{0} ق/م"}
other{"{0} ق/م"}
}
body-weight-per-second{
one{"{0} BW/s"}
other{"{0} BW/s"}
}
breath-per-minute{
one{"{0} ق/م"}
other{"{0} ق/م"}
}
foot-per-hour{
one{"{0} ft/h"}
other{"{0} ft/h"}
}
jump-rope-per-minute{
one{"{0} ئاتلام/مىنۇت"}
other{"{0} ئاتلام/مىنۇت"}
}
meter-per-hour{
one{"{0} m/h"}
other{"{0} m/h"}
}
milliliter-per-minute-per-kilogram{
one{"{0} ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
one{"{0} ق/م"}
other{"{0} ق/م"}
}
step-per-minute{
one{"{0} قەدەم/مىنۇت"}
other{"{0} قەدەم/مىنۇت"}
}
stroke-per-minute{
one{"{0} پالاق/مىنۇت"}
other{"{0} پالاق/مىنۇت"}
}
}

View File

@ -0,0 +1,42 @@
zohos{
beat-per-minute{
dnam{"次/分钟"}
other{"{0} 次/分钟"}
}
body-weight-per-second{
dnam{"BW/s"}
other{"{0} BW/s"}
}
breath-per-minute{
dnam{"次/分"}
other{"{0} 次/分"}
}
foot-per-hour{
dnam{"英尺/小时"}
other{"{0} 英尺/小时"}
}
jump-rope-per-minute{
dnam{"个/分钟"}
other{"{0} 个/分钟"}
}
meter-per-hour{
dnam{"米/小时"}
other{"{0} 米/小时"}
}
milliliter-per-minute-per-kilogram{
dnam{"ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
dnam{"转/分钟"}
other{"{0} 转/分钟"}
}
step-per-minute{
dnam{"步/分钟"}
other{"{0} 步/分钟"}
}
stroke-per-minute{
dnam{"次/分钟"}
other{"{0} 次/分钟"}
}
}

View File

@ -0,0 +1,42 @@
zohos{
beat-per-minute{
dnam{"次/分鐘"}
other{"{0} 次/分鐘"}
}
body-weight-per-second{
dnam{"BW/s"}
other{"{0} BW/s"}
}
breath-per-minute{
dnam{"次/分"}
other{"{0} 次/分"}
}
foot-per-hour{
dnam{"英尺/小時"}
other{"{0} 英尺/小時"}
}
jump-rope-per-minute{
dnam{"個/分鐘"}
other{"{0} 個/分鐘"}
}
meter-per-hour{
dnam{"公尺/小時"}
other{"{0} 公尺/小時"}
}
milliliter-per-minute-per-kilogram{
dnam{"ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
dnam{"轉/分鐘"}
other{"{0} 轉/分鐘"}
}
step-per-minute{
dnam{"步/分鐘"}
other{"{0} 步/分鐘"}
}
stroke-per-minute{
dnam{"次/分鐘"}
other{"{0} 次/分鐘"}
}
}

View File

@ -0,0 +1,42 @@
zohos{
beat-per-minute{
dnam{"下/分鐘"}
other{"{0} 下/分鐘"}
}
body-weight-per-second{
dnam{"體重/秒"}
other{"{0} 體重/秒"}
}
breath-per-minute{
dnam{"下/分鐘"}
other{"{0} 下/分鐘"}
}
foot-per-hour{
dnam{"呎/小時"}
other{"{0} 呎/小時"}
}
jump-rope-per-minute{
dnam{"下/分鐘"}
other{"{0} 下/分鐘"}
}
meter-per-hour{
dnam{"米/小時"}
other{"{0} 米/小時"}
}
milliliter-per-minute-per-kilogram{
dnam{"ml/kg/min"}
other{"{0} ml/kg/min"}
}
rotation-per-minute{
dnam{"轉/分鐘"}
other{"{0} 轉/分鐘"}
}
step-per-minute{
dnam{"步/分鐘"}
other{"{0} 步/分鐘"}
}
stroke-per-minute{
dnam{"下/分鐘"}
other{"{0} 下/分鐘"}
}
}

View File

@ -0,0 +1,108 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import os
def add_content(data, src_content, prefix=''):
if len(prefix) == 0:
for content in src_content:
data = data + ' ' + content + '\n'
else:
data = data + ' ' + prefix + '{' + '\n'
for content in src_content:
data = data + ' ' + content + '\n'
data = data + ' }' + '\n'
return data
def copy_content(src_file, dest_file, out_file):
if os.path.exists(src_file):
with open(src_file, 'r', encoding='utf-8') as f:
src_content = f.read().splitlines()
else:
src_content = []
with open(dest_file, 'r', encoding='utf-8') as f:
dest_content = f.read().splitlines(True)
data = ''
signal = 0
for index in range(len(dest_content)):
line = dest_content[index]
if (index == len(dest_content) - 1) and (signal != 3):
if signal == 0:
data = add_content(data, src_content, 'units')
signal = 1
if signal == 1:
data = add_content(data, src_content, 'unitsNarrow')
signal = 2
if signal == 2:
data = add_content(data, src_content, 'unitsShort')
data += line
elif ('unitsShort{' in line) or ('unitsShort:' in line):
if signal == 0:
data = add_content(data, src_content, 'units')
signal = 1
if signal == 1:
data = add_content(data, src_content, 'unitsNarrow')
data += line
if 'unitsShort{' in line:
data = add_content(data, src_content)
signal = 3
elif ('unitsNarrow{' in line) or ('unitsNarrow:' in line):
if signal == 0:
data = add_content(data, src_content, 'units')
data += line
if 'unitsNarrow{' in line:
data = add_content(data, src_content)
signal = 2
elif ('units{' in line) or ('units:' in line):
data += line
if 'units{' in line:
data = add_content(data, src_content)
signal = 1
else:
data += line
with open(out_file, 'w', encoding='utf-8') as f:
f.write(data)
def copy_file(src_file, dest_file):
with open(src_file, 'r', encoding='utf-8') as f:
data = f.read()
with open(dest_file, 'w', encoding='utf-8') as f:
f.write(data)
if __name__=='__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--icu_src_dir', type=str)
parser.add_argument('--ohos_src_dir', type=str)
parser.add_argument('--out_dir', type=str)
args = parser.parse_args()
out_dir = args.out_dir + '/out/temp/'
unit_path = '/unit/'
filter_file = '/data_filter.json'
os.makedirs(out_dir + unit_path, exist_ok=True)
for file in os.listdir(args.ohos_src_dir + unit_path):
copy_content(args.ohos_src_dir + unit_path + file,
args.icu_src_dir + unit_path + file, out_dir + unit_path + file)
copy_file(args.ohos_src_dir + filter_file, out_dir + filter_file)

View File

@ -61,6 +61,11 @@ icu_data_filter_file="$script_path/$icu_data_filter_dir/data_filter.json"
rm -rf "$out_put_root_path/thirdparty/icu/out/*" rm -rf "$out_put_root_path/thirdparty/icu/out/*"
python3 $script_path/ohos_data.py \
--icu_src_dir "$icu_source_path/source/data" \
--ohos_src_dir "$script_path/$icu_data_filter_dir/" \
--out_dir "$out_put_root_path/thirdparty/icu" \
gen_icu_data() { gen_icu_data() {
# compile to res file # compile to res file
@ -68,7 +73,7 @@ gen_icu_data() {
--src_dir $icu_source_path/source/data \ --src_dir $icu_source_path/source/data \
--include_uni_core_data \ --include_uni_core_data \
--seqmode sequential \ --seqmode sequential \
--filter_file $icu_data_filter_file \ --filter_file $out_put_root_path/thirdparty/icu/out/temp/data_filter.json \
--mode unix-exec \ --mode unix-exec \
--tool_dir $tool_bin_dir \ --tool_dir $tool_bin_dir \
--out_dir $res_out_root_dir/out/build/$icu_dat_name \ --out_dir $res_out_root_dir/out/build/$icu_dat_name \