From: Niklas L. <nik...@gm...> - 2011-02-19 20:43:41
|
On 6 February 2011 14:29, Michael Vehrs <Mic...@gm...> wrote: > The ChoiceFormat consists of two opening brackets, a tag, a selector, > one or several choices, and two closing brackets: > > {{TAG:SELECTOR|CHOICE[|CHOICE...]}} > > The tag determines how the selector is to be interpreted. At the > moment, the only two tags defined are PLURAL and INDEX. In both cases, > the selector must evaluate to an integer. In other words, it must > either be the string representation of a non-negative decimal number > (e.g. "3"), or a variable whose value is an integer (i.e. "%number%"). > > If the tag is INDEX, the selector directly selects the choice with the > same index. If the tag is PLURAL, the selector will be converted to an > index by applying the appropriate CLDR rules first. CLDR rules don't use numerical indexes, instead they have keys like zero, one, two, few, many, other. > > If there is only a single choice, then that choice MUST evaluate to > the key of another string template, to which the tag and selector are > then applied. For example: > > key.france={{INDEX:0|France|French|French people}} > key.greeting=The {{INDEX:2|%nation%}} are happy to see you. > > If the value of the variable %nation% is "key.france", then the > template "key.greeting" will be expanded as follows: > > (1) The {{INDEX:2|key.france}} are happy to see you. > (2) The {{INDEX:2|France|French|French people}} are happy to see you. > (3) The French people are happy to see you. Here too having string keys would aid readability a lot - and we know translators are usually not programmers. Would it be possible to have string keys with reasonable effort? In general this syntax seems flexible, which is very important in FreeCol due to how the sentences necessarily contain some lego building. Yet it similar enough what translators might already have seen in twn, and I guess this is pretty much the simplest solution given the requirements. There are few things that I'd like present that are relevant for this discussion. Given example sentence like (4), how would the syntax go since both the number and the target are variables. It's not obvious from your examples. In languages that might need to combine number with cases, how would that go? (4) You sold %number% %goods%. And one more thing. In (4) %number% is the unformatted number because it needs to be converted to plural index. However the %number% that is displayed to the user should be formatted (thousand and decimal separators, non-arabic numerals). How to solve this? Either provide two variables, one formatted and one unformatted, or make the plural indexing so that it can accept formatted numbers -- this is how MediaWiki does it. -Niklas -- Niklas Laxström |