What are some good non-English phrases with singular and plural forms that can be used to test an internationalization and localization library?
I've been开发者_如何学JAVA working on a .NET library to assist with internationalization of an application. It's written in C#, called SmartFormat, and is open-source on GitHub.
It contains Grammatical Number rules for multiple languages that determine the correct singular/plural form based on the template and locale. The rules were obtained from Unicode Language Plural Rules.
When translating a phrase that has words that depend on a quantity (such as nouns, verbs, and adjectives), you specify the multiple forms and the formatter chooses the correct form based on these rules.
An example in English: (notice the syntax is nearly identical to String.Format
)
var message = "There {0:is:are} {0} {0:item:items} remaining.";
var output = Smart.Format(culture, message, items.Count);
I would like to write unit tests for many of the supported languages. However, I only speak English and Spanish (which both have the same grammatical-number rules).
What are some good non-English test phrases that can be used for these unit tests?
I am looking for phrases similar to "There {0:is:are} {0} {0:item:items} remaining."
. Notice how this example requires a specific verb and noun based on the quantity.
A note about syntax:
This library looks for :
delimited words and chooses the correct word based on the rules defined for the locale. For example, in Polish, there are 3 plural forms for the word "File" : 1 "plik", 2-4 "pliki", 5-21 "plików". So, you would specify all 3 forms in the format string: "{0} {0:plik:pliki:plików}"
.
The words are typically ordered from smallest possible value to largest, such as "{0:zero:one:two:few:many:other}"
, as defined by the Unicode Language Plural Rules.
Additional information about this code has been discussed here: Localization of singular/plural words - what are the different language rules for grammatical numbers?
I'd like to contribute with the approximate Turkish translation of your sample phrase, so you can test for the case where number of possible forms equals 1. ;)
{0} nesne kaldı.
= ({0} items remaining.)
Although Turkish words are pluralized regularly with suffixes, the plural forms are never used when the number of items are specified. So the above should be rendered the same in each case:
1 nesne kaldı.
2 nesne kaldı.
42 nesne kaldı.
However, when the count is not explicitly specified, it may become grammatically important to indicate if we are talking about one or more items. So the message "Do you want to delete the selected item(s)?
" should be rendered like this:
Seçili nesneyi silmek istiyor musunuz?
(when item count=1)
Seçili nesneleri silmek istiyor musunuz?
(when item count>1)
So I guess the format for this would be:
Seçili {0:nesneyi:nesneleri} silmek istiyor musunuz?
精彩评论