(svn r16129) -Feature-ish: configurable digit group separator per language with user override.
This commit is contained in:
@@ -71,6 +71,8 @@ static int _next_string_id;
|
||||
|
||||
static uint32 _hash;
|
||||
static char _lang_name[32], _lang_ownname[32], _lang_isocode[16];
|
||||
static char _lang_digit_group_separator[8];
|
||||
static char _lang_digit_group_separator_currency[8];
|
||||
static byte _lang_pluralform;
|
||||
static byte _lang_textdir;
|
||||
static uint16 _lang_winlangid;
|
||||
@@ -526,6 +528,12 @@ static void HandlePragma(char *str)
|
||||
} else {
|
||||
error("Invalid textdir %s", str + 8);
|
||||
}
|
||||
} else if (!memcmp(str, "digitsep ", 9)) {
|
||||
str += 9;
|
||||
strecpy(_lang_digit_group_separator, strcmp(str, "{NBSP}") == 0 ? "\xC2\xA0" : str, lastof(_lang_digit_group_separator));
|
||||
} else if (!memcmp(str, "digitsepcur ", 12)) {
|
||||
str += 12;
|
||||
strecpy(_lang_digit_group_separator_currency, strcmp(str, "{NBSP}") == 0 ? "\xC2\xA0" : str, lastof(_lang_digit_group_separator_currency));
|
||||
} else if (!memcmp(str, "winlangid ", 10)) {
|
||||
const char *buf = str + 10;
|
||||
long langid = strtol(buf, NULL, 16);
|
||||
@@ -802,6 +810,8 @@ static void ParseFile(const char *file, bool english)
|
||||
/* For each new file we parse, reset the genders, and language codes */
|
||||
_numgenders = 0;
|
||||
_lang_name[0] = _lang_ownname[0] = _lang_isocode[0] = '\0';
|
||||
strecpy(_lang_digit_group_separator, ",", lastof(_lang_digit_group_separator));
|
||||
strecpy(_lang_digit_group_separator_currency, ",", lastof(_lang_digit_group_separator_currency));
|
||||
_lang_textdir = TD_LTR;
|
||||
_lang_winlangid = 0x0000; // neutral language code
|
||||
_lang_newgrflangid = 0; // standard english
|
||||
@@ -1059,6 +1069,8 @@ static void WriteLangfile(const char *filename)
|
||||
strecpy(hdr.name, _lang_name, lastof(hdr.name));
|
||||
strecpy(hdr.own_name, _lang_ownname, lastof(hdr.own_name));
|
||||
strecpy(hdr.isocode, _lang_isocode, lastof(hdr.isocode));
|
||||
strecpy(hdr.digit_group_separator, _lang_digit_group_separator, lastof(hdr.digit_group_separator));
|
||||
strecpy(hdr.digit_group_separator_currency, _lang_digit_group_separator_currency, lastof(hdr.digit_group_separator_currency));
|
||||
|
||||
fwrite(&hdr, sizeof(hdr), 1, f);
|
||||
|
||||
|
@@ -5,15 +5,21 @@
|
||||
#ifndef STRGEN_H
|
||||
#define STRGEN_H
|
||||
|
||||
/** Header of a language file. */
|
||||
struct LanguagePackHeader {
|
||||
uint32 ident; // 32-bits identifier
|
||||
uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h
|
||||
char name[32]; // the international name of this language
|
||||
char own_name[32]; // the localized name of this language
|
||||
char isocode[16]; // the ISO code for the language (not country code)
|
||||
uint16 offsets[32]; // the offsets
|
||||
byte plural_form; // plural form index
|
||||
byte text_dir; // default direction of the text
|
||||
uint32 ident; ///< 32-bits identifier
|
||||
uint32 version; ///< 32-bits of auto generated version info which is basically a hash of strings.h
|
||||
char name[32]; ///< the international name of this language
|
||||
char own_name[32]; ///< the localized name of this language
|
||||
char isocode[16]; ///< the ISO code for the language (not country code)
|
||||
uint16 offsets[32]; ///< the offsets
|
||||
|
||||
/** Thousand separator used for anything not currencies */
|
||||
char digit_group_separator[8];
|
||||
/** Thousand separator used for currencies */
|
||||
char digit_group_separator_currency[8];
|
||||
byte plural_form; ///< plural form index
|
||||
byte text_dir; ///< default direction of the text
|
||||
/**
|
||||
* Windows language ID:
|
||||
* Windows cannot and will not convert isocodes to something it can use to
|
||||
@@ -22,9 +28,9 @@ struct LanguagePackHeader {
|
||||
* what language it is in "Windows". The ID is the 'locale identifier' on:
|
||||
* http://msdn.microsoft.com/en-us/library/ms776294.aspx
|
||||
*/
|
||||
uint16 winlangid; // windows language id
|
||||
uint8 newgrflangid; // newgrf language id
|
||||
byte pad[3]; // pad header to be a multiple of 4
|
||||
uint16 winlangid; ///< windows language id
|
||||
uint8 newgrflangid; ///< newgrf language id
|
||||
byte pad[3]; ///< pad header to be a multiple of 4
|
||||
};
|
||||
|
||||
assert_compile(sizeof(LanguagePackHeader) % 4 == 0);
|
||||
|
Reference in New Issue
Block a user