Skip to content

Add chinese abbreviations for area,length,mass units #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions CodeGen/PrefixInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using CodeGen.JsonTypes;
Expand All @@ -11,33 +11,34 @@ namespace CodeGen
internal class PrefixInfo
{
private const string Russian = "ru-RU";
private const string Chinese = "zh-CN";

public static readonly IReadOnlyDictionary<Prefix, PrefixInfo> Entries = new[]
{
// Need to append 'd' suffix for double in order to later search/replace "d" with "m"
// when creating decimal conversion functions in CodeGen.Generator.FixConversionFunctionsForDecimalValueTypes.

// SI prefixes
new PrefixInfo(Prefix.Yocto, "1e-24d", "y"),
new PrefixInfo(Prefix.Zepto, "1e-21d", "z"),
new PrefixInfo(Prefix.Atto, "1e-18d", "a", (Russian, "а")),
new PrefixInfo(Prefix.Femto, "1e-15d", "f", (Russian, "ф")),
new PrefixInfo(Prefix.Pico, "1e-12d", "p", (Russian, "п")),
new PrefixInfo(Prefix.Nano, "1e-9d", "n", (Russian, "н")),
new PrefixInfo(Prefix.Micro, "1e-6d", "µ", (Russian, "мк")),
new PrefixInfo(Prefix.Milli, "1e-3d", "m", (Russian, "м")),
new PrefixInfo(Prefix.Centi, "1e-2d", "c", (Russian, "с")),
new PrefixInfo(Prefix.Deci, "1e-1d", "d", (Russian, "д")),
new PrefixInfo(Prefix.Deca, "1e1d", "da", (Russian, "да")),
new PrefixInfo(Prefix.Hecto, "1e2d", "h", (Russian, "г")),
new PrefixInfo(Prefix.Kilo, "1e3d", "k", (Russian, "к")),
new PrefixInfo(Prefix.Mega, "1e6d", "M", (Russian, "М")),
new PrefixInfo(Prefix.Giga, "1e9d", "G", (Russian, "Г")),
new PrefixInfo(Prefix.Tera, "1e12d", "T", (Russian, "Т")),
new PrefixInfo(Prefix.Peta, "1e15d", "P", (Russian, "П")),
new PrefixInfo(Prefix.Exa, "1e18d", "E", (Russian, "Э")),
new PrefixInfo(Prefix.Zetta, "1e21d", "Z"),
new PrefixInfo(Prefix.Yotta, "1e24d", "Y"),
new PrefixInfo(Prefix.Yocto, "1e-24d", "y",(Chinese, "夭")),
new PrefixInfo(Prefix.Zepto, "1e-21d", "z",(Chinese, "仄")),
new PrefixInfo(Prefix.Atto, "1e-18d", "a", (Russian, "а"),(Chinese, "阿")),
new PrefixInfo(Prefix.Femto, "1e-15d", "f", (Russian, "ф"),(Chinese, "飞")),
new PrefixInfo(Prefix.Pico, "1e-12d", "p", (Russian, "п"),(Chinese, "皮")),
new PrefixInfo(Prefix.Nano, "1e-9d", "n", (Russian, "н"),(Chinese, "纳")),
new PrefixInfo(Prefix.Micro, "1e-6d", "µ", (Russian, "мк"),(Chinese, "微")),
new PrefixInfo(Prefix.Milli, "1e-3d", "m", (Russian, "м"),(Chinese, "毫")),
new PrefixInfo(Prefix.Centi, "1e-2d", "c", (Russian, "с"),(Chinese, "厘")),
new PrefixInfo(Prefix.Deci, "1e-1d", "d", (Russian, "д"),(Chinese, "分")),
new PrefixInfo(Prefix.Deca, "1e1d", "da", (Russian, "да"),(Chinese, "十")),
new PrefixInfo(Prefix.Hecto, "1e2d", "h", (Russian, "г"),(Chinese, "百")),
new PrefixInfo(Prefix.Kilo, "1e3d", "k", (Russian, "к"),(Chinese, "千")),
new PrefixInfo(Prefix.Mega, "1e6d", "M", (Russian, "М"),(Chinese, "兆")),
new PrefixInfo(Prefix.Giga, "1e9d", "G", (Russian, "Г"),(Chinese, "吉")),
new PrefixInfo(Prefix.Tera, "1e12d", "T", (Russian, "Т"),(Chinese, "太")),
new PrefixInfo(Prefix.Peta, "1e15d", "P", (Russian, "П"),(Chinese, "拍")),
new PrefixInfo(Prefix.Exa, "1e18d", "E", (Russian, "Э"),(Chinese, "艾")),
new PrefixInfo(Prefix.Zetta, "1e21d", "Z",(Chinese, "泽")),
new PrefixInfo(Prefix.Yotta, "1e24d", "Y",(Chinese, "尧")),

// Binary prefixes
new PrefixInfo(Prefix.Kibi, "1024d", "Ki"),
Expand Down
62 changes: 57 additions & 5 deletions Common/UnitDefinitions/Area.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "км²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方公里" ]
}
]
},
Expand All @@ -41,6 +45,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "м²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方米" ]
}
]
},
Expand All @@ -60,6 +68,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "дм²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方分米" ]
}
]
},
Expand All @@ -79,6 +91,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "см²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方厘米" ]
}
]
},
Expand All @@ -98,6 +114,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "мм²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方毫米" ]
}
]
},
Expand All @@ -117,6 +137,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "мкм²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方微米" ]
}
]
},
Expand All @@ -136,6 +160,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "миля²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方英里" ]
}
]
},
Expand All @@ -155,6 +183,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "ярд²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方码" ]
}
]
},
Expand All @@ -174,6 +206,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "фут²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方英尺" ]
}
]
},
Expand Down Expand Up @@ -212,6 +248,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "дюйм²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方英寸" ]
}
]
},
Expand All @@ -225,9 +265,13 @@
"Culture": "en-US",
"Abbreviations": [ "ac" ]
},
{
{
"Culture": "ru-RU",
"Abbreviations": [ "акр" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "英亩" ]
}
]
},
Expand All @@ -241,9 +285,13 @@
"Culture": "en-US",
"Abbreviations": [ "ha" ]
},
{
{
"Culture": "ru-RU",
"Abbreviations": [ "га" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "英亩" ]
}
]
},
Expand All @@ -255,11 +303,15 @@
"Localization": [
{
"Culture": "en-US",
"Abbreviations": ["nmi²"]
"Abbreviations": [ "nmi²" ]
},
{
{
"Culture": "ru-RU",
"Abbreviations": ["морск.миля²"]
"Abbreviations": [ "морск.миля²" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "平方海里" ]
}
]
}
Expand Down
32 changes: 32 additions & 0 deletions Common/UnitDefinitions/Length.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "м" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "米" ]
}
]
},
Expand All @@ -42,6 +46,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "миля" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "英里" ]
}
]
},
Expand All @@ -61,6 +69,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "ярд" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "码" ]
}
]
},
Expand All @@ -80,6 +92,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "фут" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "英尺" ]
}
]
},
Expand Down Expand Up @@ -114,6 +130,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "дюйм" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "英寸" ]
}
]
},
Expand All @@ -133,6 +153,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "мил" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "密耳" ]
}
]
},
Expand All @@ -152,6 +176,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "мил" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "纳米" ]
}
]
},
Expand Down Expand Up @@ -201,6 +229,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "микродюйм" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "微英寸" ]
}
]
},
Expand Down
24 changes: 24 additions & 0 deletions Common/UnitDefinitions/Mass.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "г" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "克" ]
}
]
},
Expand All @@ -43,6 +47,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "т" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "吨" ]
}
]
},
Expand All @@ -64,6 +72,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "тонна малая" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "短吨" ]
}
]
},
Expand All @@ -85,6 +97,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "тонна большая" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "长吨" ]
}
]
},
Expand All @@ -106,6 +122,10 @@
{
"Culture": "ru-RU",
"Abbreviations": [ "фунт" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "磅" ]
}
]
},
Expand All @@ -123,6 +143,10 @@
{
"Culture": "en-US",
"Abbreviations": [ "oz" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "盎司" ]
}
]
},
Expand Down
Loading