File diff r23537:f6a6d4ce4bd5 → r23538:8df50944b27a
src/language.h
Show inline comments
 
@@ -51,64 +51,64 @@ struct LanguagePackHeader {
 
	 *   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;
 

	
 
	/**
 
	 * 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. */
 
assert_compile(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 SmallVector<LanguageMetadata, 4> LanguageList;
 
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 icu::Collator *_current_collator;
 
#endif /* WITH_ICU_I18N */
 

	
 
bool ReadLanguagePack(const LanguageMetadata *lang);
 
const LanguageMetadata *GetLanguage(byte newgrflangid);
 

	
 
#endif /* LANGUAGE_H */