OpenTTD Source 20250501-master-ga30f251d05
strgen_base.cpp File Reference

Tool to create computer readable (stand-alone) translation files. More...

Go to the source code of this file.

Data Structures

struct  ParsedCommandString
 

Functions

static ParsedCommandString ParseCommandString (StringConsumer &consumer)
 
static size_t TranslateArgumentIdx (size_t arg, size_t offset=0)
 
static uint32_t VersionHashStr (uint32_t hash, std::string_view s)
 Create a compound hash.
 
void EmitSingleChar (StringBuilder &builder, std::string_view param, char32_t value)
 
static std::pair< std::optional< size_t >, std::optional< size_t > > ParseRelNum (StringConsumer &consumer)
 
std::optional< std::string_view > ParseWord (StringConsumer &consumer)
 
static void EmitWordList (StringBuilder &builder, const std::vector< std::string > &words)
 
void EmitPlural (StringBuilder &builder, std::string_view param, char32_t)
 
void EmitGender (StringBuilder &builder, std::string_view param, char32_t)
 
static const CmdStructFindCmd (std::string_view s)
 
static uint8_t ResolveCaseName (std::string_view str)
 
ParsedCommandStruct ExtractCommandString (std::string_view s, bool)
 
const CmdStructTranslateCmdForCompare (const CmdStruct *a)
 
static bool CheckCommandsMatch (std::string_view a, std::string_view b, std::string_view name)
 
static std::string_view StripTrailingWhitespace (std::string_view str)
 
static void PutArgidxCommand (StringBuilder &builder)
 
static std::string PutCommandString (std::string_view str)
 

Variables

StrgenState _strgen
 
static bool _translated
 Whether the current language is not the master language.
 
static std::string_view _cur_ident
 
static ParsedCommandStruct _cur_pcs
 
static size_t _cur_argidx
 

Detailed Description

Tool to create computer readable (stand-alone) translation files.

Definition in file strgen_base.cpp.

Function Documentation

◆ CheckCommandsMatch()

static bool CheckCommandsMatch ( std::string_view  a,
std::string_view  b,
std::string_view  name 
)
static

Definition at line 431 of file strgen_base.cpp.

◆ EmitGender()

void EmitGender ( StringBuilder builder,
std::string_view  param,
char32_t  value 
)

Definition at line 275 of file strgen_base.cpp.

◆ EmitPlural()

void EmitPlural ( StringBuilder builder,
std::string_view  param,
char32_t  value 
)

Definition at line 220 of file strgen_base.cpp.

◆ EmitSingleChar()

void EmitSingleChar ( StringBuilder builder,
std::string_view  param,
char32_t  value 
)

Definition at line 167 of file strgen_base.cpp.

◆ EmitWordList()

static void EmitWordList ( StringBuilder builder,
const std::vector< std::string > &  words 
)
static

Definition at line 207 of file strgen_base.cpp.

◆ ExtractCommandString()

ParsedCommandStruct ExtractCommandString ( std::string_view  s,
bool  warnings 
)

Definition at line 384 of file strgen_base.cpp.

◆ FindCmd()

static const CmdStruct * FindCmd ( std::string_view  s)
static

Definition at line 314 of file strgen_base.cpp.

◆ ParseCommandString()

static ParsedCommandString ParseCommandString ( StringConsumer consumer)
static

Definition at line 330 of file strgen_base.cpp.

◆ ParseRelNum()

static std::pair< std::optional< size_t >, std::optional< size_t > > ParseRelNum ( StringConsumer consumer)
static

Definition at line 175 of file strgen_base.cpp.

◆ ParseWord()

std::optional< std::string_view > ParseWord ( StringConsumer consumer)

Definition at line 189 of file strgen_base.cpp.

◆ PutArgidxCommand()

static void PutArgidxCommand ( StringBuilder builder)
static

Definition at line 658 of file strgen_base.cpp.

◆ PutCommandString()

static std::string PutCommandString ( std::string_view  str)
static

Definition at line 664 of file strgen_base.cpp.

◆ ResolveCaseName()

static uint8_t ResolveCaseName ( std::string_view  str)
static

Definition at line 322 of file strgen_base.cpp.

◆ StripTrailingWhitespace()

static std::string_view StripTrailingWhitespace ( std::string_view  str)
static

Definition at line 482 of file strgen_base.cpp.

◆ TranslateArgumentIdx()

static size_t TranslateArgumentIdx ( size_t  arg,
size_t  offset = 0 
)
static

Definition at line 634 of file strgen_base.cpp.

◆ TranslateCmdForCompare()

const CmdStruct * TranslateCmdForCompare ( const CmdStruct a)

Definition at line 413 of file strgen_base.cpp.

◆ VersionHashStr()

static uint32_t VersionHashStr ( uint32_t  hash,
std::string_view  s 
)
static

Create a compound hash.

Parameters
hashThe hash to add the string hash to.
sThe string hash.
Returns
The new hash.

Definition at line 117 of file strgen_base.cpp.

Referenced by StringData::Version().

Variable Documentation

◆ _cur_argidx

size_t _cur_argidx
static

Definition at line 28 of file strgen_base.cpp.

◆ _cur_ident

std::string_view _cur_ident
static

Definition at line 26 of file strgen_base.cpp.

◆ _cur_pcs

ParsedCommandStruct _cur_pcs
static

Definition at line 27 of file strgen_base.cpp.

◆ _strgen

StrgenState _strgen

Definition at line 24 of file strgen_base.cpp.

◆ _translated

bool _translated
static

Whether the current language is not the master language.

Definition at line 25 of file strgen_base.cpp.

Referenced by LanguageWriter::WriteLang().