OpenTTD Source: LanguagePackHeader Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields | Static Public Attributes
LanguagePackHeader Struct Reference

Header of a language file. More...

`#include <language.h>`

Inheritance diagram for LanguagePackHeader:

## Public Member Functions
bool | IsValid () const
| Check whether the header is a valid header for OpenTTD.
bool | IsReasonablyFinished () const
| Check whether a translation is sufficiently finished to offer it to the public.
uint8_t | GetGenderIndex (std::string_view gender_str) const
| Get the index for the given gender.
uint8_t | GetCaseIndex (std::string_view case_str) const
| Get the index for the given case.

## Data Fields
uint32_t | ident = 0
| 32-bits identifier
uint32_t | version = 0
| 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_t | offsets [TEXT_TAB_END] = {}
| the offsets
char | digit_group_separator [8] = ","
| Thousand separator used for anything not currencies.
char | digit_group_separator_currency [8] = ","
| Thousand separator used for currencies.
char | digit_decimal_separator [8] = "."
| Decimal separator.
uint16_t | missing = 0
| number of missing strings.
uint8_t | plural_form = 0
| plural form index
uint8_t | text_dir = 0
| default direction of the text
uint16_t | winlangid = 0
| Windows language ID: Windows cannot and will not convert isocodes to something it can use to determine whether a font can be used for the language or not.
uint8_t | newgrflangid = 0
| newgrf language id
uint8_t | num_genders = 0
| the number of genders of this language
uint8_t | num_cases = 0
| the number of cases of this language
uint8_t | pad [3] = {}
| pad header to be a multiple of 4
char | genders [MAX_NUM_GENDERS][CASE_GENDER_LEN] = {}
| the genders used by this translation
char | cases [MAX_NUM_CASES][CASE_GENDER_LEN] = {}
| the cases used by this translation

## Static Public Attributes
static const uint32_t | IDENT = 0x474E414C
| Identifier for OpenTTD language files, big endian for "LANG".

## Detailed Description

Header of a language file.

Definition at line 24 of file language.h.

## Member Function Documentation

## ◆ GetCaseIndex()

uint8_t LanguagePackHeader::GetCaseIndex | ( | std::string_view | case_str | ) | const
| inline

Get the index for the given case.

Parameters

  case_str | The string representation of the case.

Returns
  The index of the case, or MAX_NUM_CASES when the case is unknown.

Definition at line 79 of file language.h.

Referenced by GlobalVarChangeInfo().

## ◆ GetGenderIndex()

uint8_t LanguagePackHeader::GetGenderIndex | ( | std::string_view | gender_str | ) | const
| inline

Get the index for the given gender.

Parameters

  gender_str | The string representation of the gender.

Returns
  The index of the gender, or MAX_NUM_GENDERS when the gender is unknown.

Definition at line 68 of file language.h.

Referenced by GlobalVarChangeInfo().

## ◆ IsReasonablyFinished()

bool LanguagePackHeader::IsReasonablyFinished | ( |  | ) | const

Check whether a translation is sufficiently finished to offer it to the public.

Definition at line 2037 of file strings.cpp.

References missing.

## ◆ IsValid()

bool LanguagePackHeader::IsValid | ( |  | ) | const

Check whether the header is a valid header for OpenTTD.

Returns
  true iff the header is deemed valid.

Definition at line 2017 of file strings.cpp.

References digit_decimal_separator, digit_group_separator, digit_group_separator_currency, IDENT, ident, isocode, MAX_LANG, MAX_NUM_CASES, MAX_NUM_GENDERS, name, newgrflangid, num_cases, num_genders, own_name, plural_form, StrValid(), text_dir, and version.

Referenced by GetLanguageFileHeader().

## Field Documentation

## ◆ cases

char LanguagePackHeader::cases[MAX_NUM_CASES][CASE_GENDER_LEN] = {}

the cases used by this translation

Definition at line 58 of file language.h.

Referenced by FileStringReader::HandlePragma().

## ◆ digit_decimal_separator

char LanguagePackHeader::digit_decimal_separator[8] = "."

Decimal separator.

Definition at line 39 of file language.h.

Referenced by FileStringReader::HandlePragma(), and IsValid().

## ◆ digit_group_separator

char LanguagePackHeader::digit_group_separator[8] = ","

Thousand separator used for anything not currencies.

Definition at line 35 of file language.h.

Referenced by FileStringReader::HandlePragma(), and IsValid().

## ◆ digit_group_separator_currency

char LanguagePackHeader::digit_group_separator_currency[8] = ","

Thousand separator used for currencies.

Definition at line 37 of file language.h.

Referenced by FileStringReader::HandlePragma(), and IsValid().

## ◆ genders

char LanguagePackHeader::genders[MAX_NUM_GENDERS][CASE_GENDER_LEN] = {}

the genders used by this translation

Definition at line 57 of file language.h.

Referenced by FileStringReader::HandlePragma().

## ◆ IDENT

const uint32_t LanguagePackHeader::IDENT = 0x474E414C
| static

Identifier for OpenTTD language files, big endian for "LANG".

Definition at line 25 of file language.h.

Referenced by IsValid(), and LanguageWriter::WriteLang().

## ◆ ident

uint32_t LanguagePackHeader::ident = 0

32-bits identifier

Definition at line 27 of file language.h.

Referenced by IsValid(), and LanguageWriter::WriteLang().

## ◆ isocode

char LanguagePackHeader::isocode[16] = ""

the ISO code for the language (not country code)

Definition at line 31 of file language.h.

Referenced by FileStringReader::HandlePragma(), InitializeLanguagePacks(), ICUParagraphLayoutFactory::InitializeLayouter(), IsValid(), FileStringReader::ParseFile(), ReadLanguagePack(), ICURun::Shape(), and SurveyConfiguration().

## ◆ missing

uint16_t LanguagePackHeader::missing = 0

number of missing strings.

Definition at line 40 of file language.h.

Referenced by SelectGameWindow::DrawWidget(), GetLanguageFileHeader(), IsReasonablyFinished(), SelectGameWindow::OnInit(), SelectGameWindow::OnResize(), and LanguageWriter::WriteLang().

## ◆ name

char LanguagePackHeader::name[32] = ""

the international name of this language

Definition at line 29 of file language.h.

Referenced by FileStringReader::HandlePragma(), IsValid(), FileStringReader::ParseFile(), and SurveyConfiguration().

## ◆ newgrflangid

uint8_t LanguagePackHeader::newgrflangid = 0

newgrf language id

Definition at line 52 of file language.h.

Referenced by FillLanguageList(), FileStringReader::HandlePragma(), IsValid(), and ReadLanguagePack().

## ◆ num_cases

uint8_t LanguagePackHeader::num_cases = 0

the number of cases of this language

Definition at line 54 of file language.h.

Referenced by UnmappedChoiceList::Flush(), FileStringReader::HandlePragma(), and IsValid().

## ◆ num_genders

uint8_t LanguagePackHeader::num_genders = 0

the number of genders of this language

Definition at line 53 of file language.h.

Referenced by UnmappedChoiceList::Flush(), FileStringReader::HandlePragma(), and IsValid().

## ◆ offsets

uint16_t LanguagePackHeader::offsets[TEXT_TAB_END] = {}

the offsets

Definition at line 32 of file language.h.

Referenced by LanguageWriter::WriteLang().

## ◆ own_name

char LanguagePackHeader::own_name[32] = ""

the localized name of this language

Definition at line 30 of file language.h.

Referenced by GameOptionsWindow::GetWidgetString(), FileStringReader::HandlePragma(), IsValid(), and FileStringReader::ParseFile().

## ◆ pad

uint8_t LanguagePackHeader::pad[3] = {}

pad header to be a multiple of 4

Definition at line 55 of file language.h.

## ◆ plural_form

uint8_t LanguagePackHeader::plural_form = 0

plural form index

Definition at line 41 of file language.h.

Referenced by StringReader::HandlePragma(), and IsValid().

## ◆ text_dir

uint8_t LanguagePackHeader::text_dir = 0

default direction of the text

Definition at line 42 of file language.h.

Referenced by FileStringReader::HandlePragma(), IsValid(), and ReadLanguagePack().

## ◆ version

uint32_t LanguagePackHeader::version = 0

32-bits of auto generated version info which is basically a hash of strings.h

Definition at line 28 of file language.h.

Referenced by IsValid(), and LanguageWriter::WriteLang().

## ◆ winlangid

uint16_t LanguagePackHeader::winlangid = 0

Windows language ID: Windows cannot and will not convert isocodes to something it can use to determine whether a font can be used for the language or not.

As a result of that we need to pass the language id via strgen to OpenTTD to tell what language it is in "Windows". The ID is the 'locale identifier' on: http://msdn.microsoft.com/en-us/library/ms776294.aspx windows language id

Definition at line 51 of file language.h.

Referenced by GetLanguageFileHeader(), FileStringReader::HandlePragma(), UniscribeItemizeString(), and LanguageWriter::WriteLang().

The documentation for this struct was generated from the following files:

- src/language.h
- src/strings.cpp