OpenTTD Source 20250428-master-ga5578166bb
|
Implementation of handling translated strings. More...
#include "../stdafx.h"
#include "../strgen/strgen.h"
#include "../debug.h"
#include "../fileio_func.h"
#include "../tar_type.h"
#include "../script/squirrel_class.hpp"
#include "../strings_func.h"
#include "game_text.hpp"
#include "game.hpp"
#include "game_info.hpp"
#include "table/strings.h"
#include "../table/strgen_tables.h"
#include "../safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | StringListReader |
A reader that simply reads using fopen. More... | |
struct | TranslationWriter |
Class for writing an encoded language. More... | |
struct | StringNameWriter |
Class for writing the string IDs. More... | |
class | LanguageScanner |
Scanner to find language files in a GameScript directory. More... | |
Functions | |
void CDECL | StrgenWarningI (const std::string &msg) |
void CDECL | StrgenErrorI (const std::string &msg) |
void CDECL | StrgenFatalI (const std::string &msg) |
LanguageStrings | ReadRawLanguageStrings (const std::string &file) |
Read all the raw language strings from the given file. | |
static std::shared_ptr< GameStrings > | LoadTranslations () |
Load all translations that we know of. | |
static StringParam::ParamType | GetParamType (const CmdStruct *cs) |
static void | ExtractStringParams (const StringData &data, StringParamsList ¶ms) |
std::string_view | GetGameStringPtr (StringIndexInTab id) |
Get the string pointer of a particular game string. | |
const StringParams & | GetGameStringParams (StringIndexInTab id) |
Get the string parameters of a particular game string. | |
const std::string & | GetGameStringName (StringIndexInTab id) |
Get the name of a particular game string. | |
void | RegisterGameTranslation (Squirrel &engine) |
Register the current translation to the Squirrel engine. | |
void | ReconsiderGameScriptLanguage () |
Reconsider the game script language, so we use the right one. | |
Variables | |
std::shared_ptr< GameStrings > | _current_gamestrings_data = nullptr |
The currently loaded game strings. | |
Implementation of handling translated strings.
Definition in file game_text.cpp.
|
static |
Definition at line 263 of file game_text.cpp.
const std::string & GetGameStringName | ( | StringIndexInTab | id | ) |
Get the name of a particular game string.
id | The ID of the game string. |
Definition at line 346 of file game_text.cpp.
References _current_gamestrings_data.
const StringParams & GetGameStringParams | ( | StringIndexInTab | id | ) |
Get the string parameters of a particular game string.
id | The ID of the game string. |
Definition at line 332 of file game_text.cpp.
References _current_gamestrings_data.
std::string_view GetGameStringPtr | ( | StringIndexInTab | id | ) |
Get the string pointer of a particular game string.
id | The ID of the game string. |
Definition at line 321 of file game_text.cpp.
References _current_gamestrings_data.
Referenced by GetStringWithArgs().
|
static |
Definition at line 256 of file game_text.cpp.
|
static |
Load all translations that we know of.
Definition at line 206 of file game_text.cpp.
References LanguageScanner::AddFile(), FioCheckFileExists(), GAME_DIR, Game::GetInfo(), ScriptInfo::GetMainScript(), ScriptInfo::GetTarFile(), ReadRawLanguageStrings(), and LanguageScanner::Scan().
Referenced by RegisterGameTranslation().
LanguageStrings ReadRawLanguageStrings | ( | const std::string & | file | ) |
Read all the raw language strings from the given file.
file | The file to read from. |
Definition at line 49 of file game_text.cpp.
References FioFOpenFile(), GAME_DIR, and LanguageStrings::lines.
Referenced by LanguageScanner::AddFile(), and LoadTranslations().
void ReconsiderGameScriptLanguage | ( | ) |
Reconsider the game script language, so we use the right one.
Definition at line 385 of file game_text.cpp.
References _current_gamestrings_data, _current_language, LanguageMetadata::file, and FS2OTTD().
Referenced by GSTRChunkHandler::Load(), ReadLanguagePack(), and RegisterGameTranslation().
void RegisterGameTranslation | ( | Squirrel & | engine | ) |
Register the current translation to the Squirrel engine.
engine | The engine to update/ |
Definition at line 359 of file game_text.cpp.
References _current_gamestrings_data, Squirrel::GetVM(), LoadTranslations(), and ReconsiderGameScriptLanguage().
Referenced by GameInstance::RegisterAPI().
void CDECL StrgenErrorI | ( | const std::string & | msg | ) |
Definition at line 32 of file game_text.cpp.
void CDECL StrgenFatalI | ( | const std::string & | msg | ) |
Definition at line 38 of file game_text.cpp.
void CDECL StrgenWarningI | ( | const std::string & | msg | ) |
Definition at line 26 of file game_text.cpp.
std::shared_ptr<GameStrings> _current_gamestrings_data = nullptr |
The currently loaded game strings.
Definition at line 314 of file game_text.cpp.
Referenced by GetGameStringName(), GetGameStringParams(), GetGameStringPtr(), GSTRChunkHandler::Load(), ReconsiderGameScriptLanguage(), RegisterGameTranslation(), and GSTRChunkHandler::Save().