mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 02:12:37 +01:00
Add: Translatable list separator. (#13149)
Some languages should use a separator other than ", " to separate list items, so it is now a translatable string.
This commit is contained in:
@@ -214,12 +214,22 @@ struct LoadedLanguagePack {
|
||||
|
||||
std::array<uint, TEXT_TAB_END> langtab_num; ///< Offset into langpack offs
|
||||
std::array<uint, TEXT_TAB_END> langtab_start; ///< Offset into langpack offs
|
||||
|
||||
std::string list_separator; ///< Current list separator string.
|
||||
};
|
||||
|
||||
static LoadedLanguagePack _langpack;
|
||||
|
||||
static bool _scan_for_gender_data = false; ///< Are we scanning for the gender of the current string? (instead of formatting it)
|
||||
|
||||
/**
|
||||
* Get the list separator string for the current language.
|
||||
* @returns string containing list separator to use.
|
||||
*/
|
||||
std::string_view GetListSeparator()
|
||||
{
|
||||
return _langpack.list_separator;
|
||||
}
|
||||
|
||||
const char *GetStringPtr(StringID string)
|
||||
{
|
||||
@@ -1311,6 +1321,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
|
||||
CargoTypes cmask = args.GetNextParameter<CargoTypes>();
|
||||
bool first = true;
|
||||
|
||||
std::string_view list_separator = GetListSeparator();
|
||||
for (const auto &cs : _sorted_cargo_specs) {
|
||||
if (!HasBit(cmask, cs->Index())) continue;
|
||||
|
||||
@@ -1318,7 +1329,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
|
||||
first = false;
|
||||
} else {
|
||||
/* Add a comma if this is not the first item */
|
||||
builder += ", ";
|
||||
builder += list_separator;
|
||||
}
|
||||
|
||||
GetStringWithArgs(builder, cs->name, args, next_substr_case_index, game_script);
|
||||
@@ -1964,6 +1975,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
||||
_current_text_dir = (TextDirection)_current_language->text_dir;
|
||||
_config_language_file = FS2OTTD(_current_language->file.filename());
|
||||
SetCurrentGrfLangID(_current_language->newgrflangid);
|
||||
_langpack.list_separator = GetString(STR_LIST_SEPARATOR);
|
||||
|
||||
#ifdef _WIN32
|
||||
extern void Win32SetCurrentLocaleName(std::string iso_code);
|
||||
|
||||
Reference in New Issue
Block a user