Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Localization like this takes consideration of the languages you want to translate to. Multiple plurals are fairly rare and I would imagine in most cases are interchangeable or context sensitive. Which unless it is being used in multiple places in your application you will not need to worry about. If you are doing this and a particular usage does create a grammatical error in plural usage then you need to add a new key across the board (all languages) for that one instance. Or, since you are detecting culture anyway, add an additional conditional for the affected language and use the single alternate plural form.</p> <p>I would not suggest avoiding it as you can quickly lose the flow of natural language "Mins answered ago: 6".</p> <p>Maybe you meant this in the first place but the far more common scenario is variations in syntactical placement across different cultures. For example, the string wanting to be localized "This page is viewed X times". You may want to make 3 localizable strings for this:</p> <p>PageViewStart = "This page is viewed" PageViewEnd = "time" PageViewEndPlural = "times"</p> <p>Then a simple pseudo-implementation would be</p> <p>PageViewStart + pageCount.ToString() + pageCount == 1 ? PageViewEnd : PageViewEndPlural;</p> <p>However in Dutch "Deze pagina is {0} keer bekeken" and in Korean "조회수 {0}". So you see you will immediatley run into problems with implementations on the multiple ways to format plural sentence structure across languages.</p> <p>I purposely left a {0} in the examples as it alludes to my solution. Use a localization for the whole sentence in plural and non-plural.</p> <p>PageView = "This page viewed 1 time." PageViewPlural = "This page viewed {0} times."</p> <p>This way you can write the conditional (pseudo again depending on your implementation):</p> <p>pageCount > 1 ? PageView : String.Format(PageViewPlural, pageCount.ToString());</p> <p>The only thing is that your translators will need to be instructed as to the meaning and placement of the {0} token in the resx file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload