summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-16 21:01:56 +0000
committerrubidium <rubidium@openttd.org>2010-11-16 21:01:56 +0000
commitebf7b915b0dee963e5398de8e06a0377c49142e6 (patch)
tree7a357823fca94e222741ffb54dbe7aaf347b7bf0 /src
parentc96cb9ce3757f90384f8cd624eb3f2878db477ff (diff)
downloadopenttd-ebf7b915b0dee963e5398de8e06a0377c49142e6.tar.xz
(svn r21215) -Codechange: store the plural form in the plural (choice) lists
Diffstat (limited to 'src')
-rw-r--r--src/strgen/strgen.cpp1
-rw-r--r--src/strings.cpp13
2 files changed, 11 insertions, 3 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index bcb44f4fe..d7a6ab0f0 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -354,6 +354,7 @@ static void EmitPlural(char *buf, int value)
}
PutUtf8(SCC_PLURAL_LIST);
+ PutByte(_lang.plural_form);
PutByte(TranslateArgumentIdx(argidx, offset));
EmitWordList(words, nw);
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 8cb362a1f..63e0df95e 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -375,12 +375,18 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
return buff;
}
-static int DeterminePluralForm(int64 count)
+/**
+ * Determine the "plural" index given a plural form and a number.
+ * @param count The number to get the plural index of.
+ * @param plural_form The plural form we want an index for.
+ * @return The plural index for the given form.
+ */
+static int DeterminePluralForm(int64 count, int plural_form)
{
/* The absolute value determines plurality */
uint64 n = abs(count);
- switch (_langpack->plural_form) {
+ switch (plural_form) {
default:
NOT_REACHED();
@@ -875,8 +881,9 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
break;
case SCC_PLURAL_LIST: { // {P}
+ int plural_form = *str++; // contains the plural form for this string
int64 v = argv_orig[(byte)*str++]; // contains the number that determines plural
- str = ParseStringChoice(str, DeterminePluralForm(v), &buff, last);
+ str = ParseStringChoice(str, DeterminePluralForm(v, plural_form), &buff, last);
break;
}