Traditionally, if you want to define a language constant (for example for the word "orange") in J! you would define two constants (a singular form and a plural form), for example:
Code: Select all
ORANGE_1="I have %d orange"
ORANGE_N="I have %d oranges"
Code: Select all
if ($orangeCount == 1) echo '<p>' . sprintf(Jtext::_("ORANGE_1"), $orangeCount) . '</p>';
else echo '<p>' . sprintf(Jtext::_("ORANGE_N"), $orangeCount) . '</p>';
if $orangeCount equals 1 orI have 1 orange
I have 0 oranges
I have 2 oranges
if $orangeCount equals 0, 2, or 256. Is that the only way to choose between using the singular form of a word stem or is there a simpler way?I have 256 oranges