Files
@ r25754:d19207ab5c69
Branch filter:
Location: cpp/openttd-patchpack/source/src/language.h - annotation
r25754:d19207ab5c69
4.4 KiB
text/x-c
Cleanup: remove SLE_NULL and friends
We no longer need them. If you want to remove a field .. just
remove it! Because of the headers in the savegame, on loading,
it will do the right thing and skip the field.
Do remember to bump the savegame version, as otherwise older
clients can still load the game, but will reset the field you
have removed .. that might be unintentially.
We no longer need them. If you want to remove a field .. just
remove it! Because of the headers in the savegame, on loading,
it will do the right thing and skip the field.
Do remember to bump the savegame version, as otherwise older
clients can still load the game, but will reset the field you
have removed .. that might be unintentially.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16438:4a3128e4430d r23455:c7e625a5235a r16603:771c410131a7 r23455:c7e625a5235a r22548:e350bbe3b5af r16438:4a3128e4430d r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r22549:21c2f1153122 r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r17987:d1baeaddc56a r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16439:74a7ff9185db r16439:74a7ff9185db r17987:d1baeaddc56a r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16434:88fcbcadb08e r16434:88fcbcadb08e r25223:b4d967fcf4cb r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16439:74a7ff9185db r16434:88fcbcadb08e r17630:7d818445376d r24521:57ec498b9221 r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16434:88fcbcadb08e r16438:4a3128e4430d r23538:8df50944b27a r16438:4a3128e4430d r16438:4a3128e4430d r16438:4a3128e4430d r16438:4a3128e4430d r16435:9850e423b4f5 r16435:9850e423b4f5 r16435:9850e423b4f5 r23455:c7e625a5235a r24527:d7a4b00784e2 r23455:c7e625a5235a r16603:771c410131a7 r16437:4ee0753a14ec r16451:22dc35cde747 r16437:4ee0753a14ec r16434:88fcbcadb08e | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file language.h Information about languages and their files. */
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include "core/smallvec_type.hpp"
#ifdef WITH_ICU_I18N
#include <unicode/coll.h>
#endif /* WITH_ICU_I18N */
#include "strings_type.h"
static const uint8 CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string.
static const uint8 MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders.
static const uint8 MAX_NUM_CASES = 16; ///< Maximum number of supported cases.
/** Header of a language file. */
struct LanguagePackHeader {
static const uint32 IDENT = 0x474E414C; ///< Identifier for OpenTTD language files, big endian for "LANG"
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[TEXT_TAB_END]; ///< 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];
/** Decimal separator */
char digit_decimal_separator[8];
uint16 missing; ///< number of missing strings.
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
* 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
*/
uint16 winlangid; ///< windows language id
uint8 newgrflangid; ///< newgrf language id
uint8 num_genders; ///< the number of genders of this language
uint8 num_cases; ///< the number of cases of this language
byte 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
bool IsValid() const;
bool IsReasonablyFinished() const;
/**
* Get the index for the given gender.
* @param gender_str The string representation of the gender.
* @return The index of the gender, or MAX_NUM_GENDERS when the gender is unknown.
*/
uint8 GetGenderIndex(const char *gender_str) const
{
for (uint8 i = 0; i < MAX_NUM_GENDERS; i++) {
if (strcmp(gender_str, this->genders[i]) == 0) return i;
}
return MAX_NUM_GENDERS;
}
/**
* Get the index for the given case.
* @param case_str The string representation of the case.
* @return The index of the case, or MAX_NUM_CASES when the case is unknown.
*/
uint8 GetCaseIndex(const char *case_str) const
{
for (uint8 i = 0; i < MAX_NUM_CASES; i++) {
if (strcmp(case_str, this->cases[i]) == 0) return i;
}
return MAX_NUM_CASES;
}
};
/** Make sure the size is right. */
static_assert(sizeof(LanguagePackHeader) % 4 == 0);
/** Metadata about a single language. */
struct LanguageMetadata : public LanguagePackHeader {
char file[MAX_PATH]; ///< Name of the file we read this data from.
};
/** Type for the list of language meta data. */
typedef std::vector<LanguageMetadata> LanguageList;
/** The actual list of language meta data. */
extern LanguageList _languages;
/** The currently loaded language. */
extern const LanguageMetadata *_current_language;
#ifdef WITH_ICU_I18N
extern std::unique_ptr<icu::Collator> _current_collator;
#endif /* WITH_ICU_I18N */
bool ReadLanguagePack(const LanguageMetadata *lang);
const LanguageMetadata *GetLanguage(byte newgrflangid);
#endif /* LANGUAGE_H */
|