UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Localization related Issues

Open LHTXQ opened this issue 2 years ago • 12 comments

Describe the bug In different languages, it is the "unit name" that should be localized, not the "unit symbol".

To Reproduce

  1. Create an application modeled after the Unit converter app;
  2. 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 image

LHTXQ avatar Dec 19 '22 14:12 LHTXQ

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.

angularsen avatar Dec 23 '22 12:12 angularsen

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. image

Finally, I'm still a beginner in programming, so I can't give this project any help on this issue.

LHTXQ avatar Dec 24 '22 06:12 LHTXQ

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

angularsen avatar Dec 26 '22 23:12 angularsen

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 厘米".

771ffdc8122e6d7edb089f47e2ca130

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

LHTXQ avatar Dec 27 '22 03:12 LHTXQ

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.

angularsen avatar Jan 07 '23 13:01 angularsen

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.

LHTXQ avatar Jan 12 '23 03:01 LHTXQ

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().

angularsen avatar Feb 12 '23 13:02 angularsen

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().

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)

LHTXQ avatar Feb 13 '23 13:02 LHTXQ

No problem, let me know when you want to proceed in any way. I'll try to assist.

angularsen avatar Feb 17 '23 07:02 angularsen

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.

LHTXQ avatar May 27 '23 12:05 LHTXQ

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

angularsen avatar May 27 '23 20:05 angularsen

你说的对。 @LHTXQ

chinasqzl avatar May 08 '24 03:05 chinasqzl

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.

github-actions[bot] avatar Jul 08 '24 18:07 github-actions[bot]

This issue was automatically closed due to inactivity.

github-actions[bot] avatar Jul 16 '24 02:07 github-actions[bot]