Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pluralising and Localizing strings in C#

I've got a C# WPF application I'm attempting to globalize with resx files. It works splendidly. I've run into a hitch, however. I've got a relatively simple solution for pluralisation where I have a singular and plural form of the string I'm displaying and I pick one based on the number of whatever things I'm talking about.

However, I've recently come to terms with the fact that some cultures have multiple plural forms. Has anyone come across a good solution to this problem in C#, let alone WPF?

The canonical example that I've seen for this problem comes from the Polish language. Polish has a singular, paucal, and plural form. This example is for the translation of the word "file":

  • 1 plik
  • 2,3,4 pliki
  • 5-21 pliko'w
  • 22-24 pliki
  • 25-31 pliko'w
like image 245
dustyburwell Avatar asked Dec 05 '22 05:12

dustyburwell


1 Answers

Mozilla has implemented this in Firefox 3, and they have a guide describing how to use their implementation here. Most notably, in the Developing with PluralForm section, they have a link

resource://gre/modules/PluralForm.jsm

to the source of their implementation. Must be opened from within Firefox 3 and higher.

I have not read through the whole thing, but this seems to be like a good place to at least get some ideas.

HTH.

like image 59
AASoft Avatar answered Dec 11 '22 09:12

AASoft