summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-10-17 17:42:51 +0000
committerrubidium <rubidium@openttd.org>2008-10-17 17:42:51 +0000
commit65404674a42eb64d9467c1828e7d5ae3a493815f (patch)
tree01b36415c49717ef5cb721a8da573f43726fd668 /src/strings.cpp
parentae0715e8c345046ef23fdd41dbc57a91b5f574f1 (diff)
downloadopenttd-65404674a42eb64d9467c1828e7d5ae3a493815f.tar.xz
(svn r14480) -Add: warning when trying to use a right-to-left language without support for it in OpenTTD.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 5d85f8cf5..ee0ad8625 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -61,7 +61,8 @@ struct LanguagePack {
char isocode[16]; // the ISO code for the language (not country code)
uint16 offsets[32]; // the offsets
byte plural_form; // how to compute plural forms
- byte pad[3]; // pad header to be a multiple of 4
+ byte text_dir; // default direction of the text
+ byte pad[2]; // pad header to be a multiple of 4
char data[VARARRAY_SIZE]; // list of strings
};
@@ -1273,6 +1274,7 @@ bool ReadLanguagePack(int lang_index)
ttd_strlcpy(_dynlang.curr_file, c_file, lengthof(_dynlang.curr_file));
_dynlang.curr = lang_index;
+ _dynlang.text_dir = (TextDirection)lang_pack->text_dir;
SetCurrentGrfLangID(_langpack->isocode);
SortNetworkLanguages();
return true;
@@ -1511,6 +1513,29 @@ void CheckForMissingGlyphsInLoadedLanguagePack()
}
}
}
+
+#if !defined(WITH_ICU)
+ /*
+ * For right-to-left languages we need the ICU library. If
+ * we do not have support for that library we warn the user
+ * about it with a message. As we do not want the string to
+ * be translated by the translators, we 'force' it into the
+ * binary and 'load' it via a BindCString. To do this
+ * properly we have to set the color of the string,
+ * otherwise we end up with a lot of artefacts. The color
+ * 'character' might change in the future, so for safety
+ * we just Utf8 Encode it into the string, which takes
+ * exactly three characters, so it replaces the "XXX" with
+ * the color marker.
+ */
+ if (_dynlang.text_dir != TD_LTR) {
+ static char *err_str = strdup("XXXThis version of OpenTTD does not support right-to-left languages. Recompile with icu enabled.");
+ Utf8Encode(err_str, SCC_YELLOW);
+ SetDParamStr(0, err_str);
+ ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
+ }
+#endif
+
}