UnitsNet
UnitsNet copied to clipboard
Localization related Issues
Describe the bug In different languages, it is the "unit name" that should be localized, not the "unit symbol".
To Reproduce
- Create an application modeled after the Unit converter app;
- Change the CultureInfo from "en-US" to "zh-CN";
Expected behavior In different languages, it is the "unit name" that should be localized, not the "unit symbol". Please see the screenshots.
Screenshots

Localization of unit names and quantity names is not yet supported. Feature discussed here: https://github.com/angularsen/UnitsNet/issues/397
If you are interested in attempting a pull request, I'm happy to assist.
I see. I also want to say that the abbreviation of the unit should not be localized. For example, "cm" should appear as "cm" in any language, not as "厘米" in Chinese. You can see the correct example in my screenshot above.
The following screenshot annotation is a little messy, I wonder if you can understand what I want to express.

Finally, I'm still a beginner in programming, so I can't give this project any help on this issue.
For example, "cm" should appear as "cm" in any language
I don't know what is correct in Chinese, but at least for Russian it seems the correct behavior is to translate "cm" to "cм". So I don't agree that it should say "cm" for all languages.
Google translate says "厘米" equals "cm", however, it also says "centimeter" equals "厘米". Does that mean there is no difference between "cm" and "centimeter" in Chinese?
Do you have some source of reference, online examples or second opinion to support removing the Chinese translation to revert to the English abbreviations instead? I don't know the conventions and standards of Chinese language.
Abbreviations were translated to Chinese in this PR: Add chinese abbreviations for area,length,mass units by chinasqzl · Pull Request #867 · angularsen/UnitsNet
I think the unit abbreviation is used after the value of the quantity. We usually write "25 cm" when we mean "25 centimeter", not "25 厘米".

We should probably replace the unit name with the translated unit abbreviation, leaving the unit abbreviation as the English representation:
centimetre - 厘米(This is the current abbreviated translation of centimeter units)
cm - cm.
The following links are examples of solutions to mechanics of materials exercises where you can see our usage of unit symbols (abbreviation): https://max.book118.com/html/2018/1004/8134135067001125.shtm
Thanks for the additional sources. I think you are correct, but I've asked for comments from the PR author in #867 to chime in here just to be extra sure.
Thanks for the additional sources. I think you are correct, but I've asked for comments from the PR author in #867 to chime in here just to be extra sure.
: |
It looks like he hasn't used Github since July of last year.
No comments from the author, I think we should just proceed with this.
@LHTXQ would you be willing to attempt a pull request? I'm happy to assist.
Generally, just edit the JSON files and run generate-code.bat after.
Detailed steps here: https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit
Note: To avoid breaking change, we need to keep the old unit abbreviations around and mark for removal in #1200 . By inserting the new, correct unit abbreviations first in the JSON array, and keeping the old ones last in the array, we will support both when parsing while the first in the array is used for ToString().
No comments from the author, I think we should just proceed with this.
@LHTXQ would you be willing to attempt a pull request? I'm happy to assist. Generally, just edit the JSON files and run
generate-code.batafter.Detailed steps here: https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit
Note: To avoid breaking change, we need to keep the old unit abbreviations around and mark for removal in #1200 . By inserting the new, correct unit abbreviations first in the JSON array, and keeping the old ones last in the array, we will support both when parsing while the first in the array is used for ToString().
I would like to contribute to this project very much, but I have been busy recently and have no time to spare. I asked a friend to do this, and if she has time she should be able to make the change quickly.
It would be great if she could translate the names of common units (units of length) as well! 😄 (College students who use love to generate electricity)
No problem, let me know when you want to proceed in any way. I'll try to assist.
Sorry, I forgot what you mentioned above #397 , forget I said any of the following...
I found that there's only "Abbreviation" property in the json file but no "SingularName" property. Does that mean I can't translate the unit name?
{
"SingularName": "Gram",
"PluralName": "Grams",
"BaseUnits": {
"M": "Gram"
},
"FromUnitToBaseFunc": "{x} / 1e3",
"FromBaseToUnitFunc": "{x} * 1e3",
"Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "g" ]
},
{
"Culture": "ru-RU",
"Abbreviations": [ "г" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "克" ]
//************************************
//No "SingularName" ?
//************************************
}
]
},
If we can translate "SingularName" property, is it possible to do this work by machine translation? In Chinese, as far as I know, almost abbreviations are the same as English, so it's easy for machine translator to tanslate only "SingularName". Maybe other languages' translation work also can be done like this.
Localization feature discussed here: https://github.com/angularsen/UnitsNet/issues/397
Also, someone started on an implementation, but progress stopped: https://github.com/angularsen/UnitsNet/pull/974
你说的对。 @LHTXQ
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was automatically closed due to inactivity.