Puralization and localization of strings in C #

I have a C # WPF application that I am trying to globalize using resx files. It works great. However, I ran into a problem. I have a relatively simple solution for pluralization, where I have the only and plural form of the string that I show, and I choose it depending on the number of things I'm talking about.

However, I recently came to an agreement with the fact that some cultures have multiple plural forms. Can anyone find a good solution to this problem in C #, not to mention WPF?

The canonical example that I saw for this problem comes from the Polish language. Polish language has a singular, pahual and plural form. This example is intended to translate the word "file":

  • 1 plik
  • 2,3,4 pliki
  • 5-21 pliko'w
  • 22-24 pliki
  • 25-31 pliko'w
+3
source share
4 answers

Mozilla implemented this in Firefox 3, and it has a guide that describes how to use their implementation here . In particular, in the section Developing with PluralForm they have a link

resource: //gre/modules/PluralForm.jsm

to the source of their implementation. Must be open from Firefox 3 and above.

I have not read all this, but it seems like a good place to at least get some ideas.

NTN.

+8
source

, . , , , . , "5 ", ": 5".

+4

, , , . , , . , , . , , ( ) . , , .

, . Mins : 6.

, , - . , , " X ". 3 :

PageViewStart = " " PageViewEnd = "" PageViewEndPlural = "times"

-

PageViewStart + pageCount.ToString() + pageCount == 1? PageViewEnd: PageViewEndPlural;

"Deze pagina is {0} keer bekeken" "조회수 {0}". , , .

{0} , . .

PageView = " 1 ." PageViewPlural = " {0} ."

( ):

pageCount > 1? PageView: String.Format(PageViewPlural, pageCount.ToString());

, {0} resx.

+2

, gettext . ( ).

This can change not only nouns-phrases (for example, in German), but not only the words "phrase".

This is much more friendly and elegant than the problem-evasive "Dateien, die nicht gelöscht werden konnten: 2", but there is a trade-off between the amount of resources you have for localization.

+1
source

Source: https://habr.com/ru/post/1717799/


All Articles