An open API service indexing awesome lists of open source software.

https://github.com/soluling/i18n

I18N Library for .NET, and Delphi
https://github.com/soluling/i18n

abbreviated-numbers angular asp-net asp-net-core cldr csharp delphi delphi-api firemonkey grammatical-genders grammatical-numbers i18n internationalization java l10n localization ordinal-numbers typescript vcl wpf

Last synced: 17 days ago
JSON representation

I18N Library for .NET, and Delphi

Awesome Lists containing this project

README

        

# Soluling's Internationalization APIs and Localization Samples

*Plurals*, *genders*, *abbreviated numbers*, *ordinal numbers*, *runtime language change*, *overlap and truncation checking*, and many more.

Soluling has implemented a collection of internationalization (I18N) APIs for [.NET](https://en.wikipedia.org/wiki/.NET_Framework), [Angular](https://en.wikipedia.org/wiki/Angular_(web_framework)) and [Delphi](https://en.wikipedia.org/wiki/Delphi_(programming_language)). Each API adds additional features to the standard I18N API of the platform — for example, support for [grammatical numbers](https://en.wikipedia.org/wiki/Grammatical_number), [grammatical genders](https://en.wikipedia.org/wiki/Grammatical_gender), abbreviated numbers, and ordinal numbers. Library also includes APIs to perform runtime language switch of applications, or to select the initial language on runtime. The library also contains API that on runtime checks your user interface for issues such as truncated or overlapped controls. Finally, the Delphi library contains a proper localization resource for [FireMonkey](https://en.wikipedia.org/wiki/FireMonkey).

## API Implementation

Each API is 100% native API. It means that it contains full source code and requires no additional files. .NET API contains only C# code and requires no other library or data files. In the same way Angular API contains only TypeScript code, and Delphi API contains only Delphi code. The rules used by the code have been extracted from [CLDR](https://en.wikipedia.org/wiki/Common_Locale_Data_Repository) into source code files that are part of the API source code. You don't need ICU library or CLDR XML files, but everything including logic and rules are compiled into your application file.

## Grammatical numbers and genders

Most resource formats (e.g., .resx in .NET, .properties in Java, and resource strings in Delphi) only support plain strings. Grammatical numbers, and genders require structural data where there are several language-depend variants for a single string. For example, in English, "I have N cars" would require two variants:

| Grammatical number | .NET | Delphi and Java |
| :----------------- | --------------- | --------------- |
| singular | I have {0} car | I have %d car |
| plural | I have {0} cars | I have %d cars |

Some platforms such as Android and Angular have built-in support for plurals, and that is why they also have a special resource format to hold multiple patterns. However, .NET, Delphi, and Java do not have such a resource format. This library uses ICU message format to store all related patterns into a standard resource string. The syntax is:

`{parameter, kind, form1 {pattern1}[ form2 {pattern2}]...[ formN {patternN}]`

where

`kind` is either `plural`, `gender` or `select`

`form` is the code for grammatical number form or for grammatical gender form.

The following table contains possible forms.

| Form | Used with | Description |
| ------- | ---------------------------------------- | ------------------------- |
| zero | Grammatical numbers | Nullar |
| one | Grammatical numbers | Singular |
| two | Grammatical numbers | Dual |
| few | Grammatical numbers | Paucal, trial or similar |
| many | Grammatical numbers | Greater paucal or similar |
| other | Grammatical numbers
Grammatical genders | Plural
Neutral |
| male | Grammatical genders | Male |
| female | Grammatical genders | Female |
| neutral | Grammatical genders | Neutral. Same as other. |

In addition of the above forms you can use operator with grammatical numbers. The operators are:

| Form | Example | Description |
| ------ | ------- | ------------------- |
| =n | =1 | Equal |
| ~n | ~12 | Around |
| >n | >5 | Greater than |
|