Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add new language #1170

Unanswered
rolandow asked this question in Q&A
Dec 15, 2022 · 1 comments · 1 reply
Discussion options

How can we add translations for an other language? Currently en-US and ru-RU seems to be defined, but how can we extend the library with our own language that does not exist in the library yet?

I assume we can define some json, and then load this to the library as well?

What would be the right procedure?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Hi, you can simply add a new localization object to a unit's Localization array.

Here is Chinese (zh-CN), for example:
https://github.com/angularsen/UnitsNet/blob/master/Common/UnitDefinitions/Length.json#L64-L77

This will have to be done for each unit you want to translate. The fallback is always en-US.

Then run generate-code.bat to update the source code.

You must be logged in to vote
1 reply
Comment options

Oh, and in some cases you may have to also specify AbbreviationsForPrefixes if you need to override the default prefixes k for kilo, M for mega etc.

Example:

"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "th (E.C.)" ],
"AbbreviationsForPrefixes": { "Deca": "Dth (E.C.)" }
},
{
"Culture": "ru-RU",
"Abbreviations": [ "Европейский терм" ],
"AbbreviationsForPrefixes": { "Deca": "Европейский декатерм" }
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /