language.h

Go to the documentation of this file.
00001 /* $Id: language.h 21343 2010-11-27 22:47:29Z terkhen $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef LANGUAGE_H
00013 #define LANGUAGE_H
00014 
00015 #include "core/smallvec_type.hpp"
00016 #ifdef WITH_ICU
00017 #include <unicode/coll.h>
00018 #endif /* WITH_ICU */
00019 
00020 static const uint8 CASE_GENDER_LEN = 16; 
00021 static const uint8 MAX_NUM_GENDERS =  8; 
00022 static const uint8 MAX_NUM_CASES   = 16; 
00023 
00025 struct LanguagePackHeader {
00026   static const uint32 IDENT = 0x474E414C; 
00027 
00028   uint32 ident;       
00029   uint32 version;     
00030   char name[32];      
00031   char own_name[32];  
00032   char isocode[16];   
00033   uint16 offsets[32]; 
00034 
00036   char digit_group_separator[8];
00038   char digit_group_separator_currency[8];
00040   char digit_decimal_separator[8];
00041   byte plural_form;   
00042   byte text_dir;      
00043 
00051   uint16 winlangid;   
00052   uint8 newgrflangid; 
00053   uint8 num_genders;  
00054   uint8 num_cases;    
00055   byte pad[1];        
00056 
00057   char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN]; 
00058   char cases[MAX_NUM_CASES][CASE_GENDER_LEN];     
00059 
00064   bool IsValid() const;
00065 
00071   uint8 GetGenderIndex(const char *gender_str) const
00072   {
00073     for (uint8 i = 0; i < MAX_NUM_GENDERS; i++) {
00074       if (strcmp(gender_str, this->genders[i]) == 0) return i;
00075     }
00076     return MAX_NUM_GENDERS;
00077   }
00078 
00084   uint8 GetCaseIndex(const char *case_str) const
00085   {
00086     for (uint8 i = 0; i < MAX_NUM_CASES; i++) {
00087       if (strcmp(case_str, this->cases[i]) == 0) return i;
00088     }
00089     return MAX_NUM_CASES;
00090   }
00091 };
00092 assert_compile(sizeof(LanguagePackHeader) % 4 == 0);
00093 
00095 struct LanguageMetadata : public LanguagePackHeader {
00096   char file[MAX_PATH]; 
00097 };
00098 
00100 typedef SmallVector<LanguageMetadata, 4> LanguageList;
00101 
00103 extern LanguageList _languages;
00104 
00106 extern const LanguageMetadata *_current_language;
00107 
00108 #ifdef WITH_ICU
00109 extern Collator *_current_collator;
00110 #endif /* WITH_ICU */
00111 
00112 bool ReadLanguagePack(const LanguageMetadata *lang);
00113 const LanguageMetadata *GetLanguage(byte newgrflangid);
00114 
00115 #endif /* LANGUAGE_H */

Generated on Fri Dec 31 17:15:32 2010 for OpenTTD by  doxygen 1.6.1