Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

language.hpp

Go to the documentation of this file.
00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file language.hpp 00022 * Manages the languages that the application knows. 00023 */ 00024 00025 00026 #ifndef INC_LANGUAGE_HPP 00027 #define INC_LANGUAGE_HPP 00028 00029 00030 //--------------------------------------------------------------------------- 00031 // For compilers that support precompilation, includes "wx.h". 00032 #include <wx/wxprec.h> 00033 00034 #ifdef __BORLANDC__ 00035 #pragma hdrstop 00036 #endif 00037 00038 #ifndef WX_PRECOMP 00039 // Include your minimal set of headers here, or wx.h 00040 #include <wx/wx.h> 00041 #endif 00042 //--------------------------------------------------------------------------- 00043 00044 00045 /** 00046 * Manages available languages for the application. 00047 * 00048 * Never pass an instance of this class by value, always pass by reference or 00049 * by adress. 00050 * 00051 * For adding a language, see the comments of the default constructor. 00052 */ 00053 class Languages 00054 { 00055 public: 00056 static const int LANGUAGE_UNKNOW; ///< Identifier for an unknown language. 00057 00058 protected: 00059 /** 00060 * Entry of the language list. 00061 * 00062 * Never pass an instance of this class by value, always pass by reference or 00063 * by adress. 00064 */ 00065 class Language 00066 { 00067 protected: 00068 wxString name; ///< Name of the language. 00069 wxString nameTranslated; ///< Name of the language (translated). 00070 wxArrayString shorts; ///< Short names that can be used for the language. 00071 wxArrayInt ids; ///< Identifiers for the languages. 00072 wxString localeName; ///< Name of the locale (compiler dependant). 00073 wxString translator; ///< Name of the translator (in latin-1 characters). 00074 wxString translatorLoc; ///< Name of the translator (in UTF-8 charset). 00075 00076 private: 00077 /// Default constructor. 00078 Language() {}; 00079 00080 public: 00081 // Constructor 00082 Language(const wxString& langName, const wxString& langNameTranslated, 00083 const wxString& shortName, const int id, const wxString& locName, 00084 const wxString& translatorLat, const wxString& translatorLocale); 00085 00086 // Other constructor 00087 Language(const wxString& langName, const wxString& langNameTranslated, 00088 const wxArrayString& shortNames, const wxArrayInt& id, 00089 const wxString& locName, const wxString& translatorLat, 00090 const wxString& translatorLocale); 00091 00092 // Sets the given locale with the given language 00093 bool setLocale(wxLocale& loc, const int language) const; 00094 00095 // Sets the given locale with the given short name 00096 bool setLocale(wxLocale& loc, const wxString& shortName) const; 00097 00098 // Gets the name of the language. 00099 wxString getName() const; 00100 00101 // Gets the translated name of the language. 00102 wxString getTranslatedName() const; 00103 00104 // Gets the language shorts names. 00105 wxArrayString getShortNames() const; 00106 00107 // Gets the main language short name. 00108 wxString getShortName() const; 00109 00110 // Gets the name of the translator (in latin-1 characters). 00111 wxString getTranslatorName() const; 00112 00113 // Gets the name of the translator in the language. 00114 wxString getTranslatorNameInLocale() const; 00115 }; 00116 00117 /// List of languages. 00118 WX_DEFINE_ARRAY(Language*, LanguagesList); 00119 00120 LanguagesList languages; ///< List of languages. 00121 00122 public: 00123 // Default constructor 00124 Languages(); 00125 00126 // Destructor 00127 ~Languages(); 00128 00129 // Sets the given locale 00130 bool setLocale(wxLocale& loc) const; 00131 00132 // Sets the given locale and force the language 00133 bool setLocale(wxLocale& loc, const int language) const; 00134 00135 // Gets the number of available languages 00136 int getLanguagesCount() const; 00137 00138 // Gets the language name at the given index 00139 wxString getLanguageName(const int index) const; 00140 00141 // Gets the language translated name at the given index 00142 wxString getLanguageTranslatedName(const int index) const; 00143 00144 // Gets the language short name at the given index 00145 wxString getLanguageShortName(const int index) const; 00146 00147 // Gets the index of language with the given short name 00148 int getLanguageIndexByShortName(const wxString& shortName) const; 00149 00150 // Gets the name of the translator (in latin-1 characters) at the given index 00151 wxString getLanguageTranslatorName(const int index) const; 00152 00153 // Gets the name of the translator in the language at the given index 00154 wxString getLanguageTranslatorNameInLocale(const int index) const; 00155 00156 protected: 00157 // Reads languages settings from a configuration file. 00158 bool readLanguagesSettings(const wxString& langFileIni); 00159 00160 00161 // For more information on the Borland C specifics, see the informations 00162 // at the end of language.cpp. 00163 #ifdef __BORLANDC__ 00164 protected: 00165 /// Array of language info 00166 WX_DEFINE_ARRAY(wxLanguageInfo*, ArrayLanguageInfo); 00167 00168 static ArrayLanguageInfo lngInfos; 00169 00170 static void CreateLanguagesDB(); 00171 static void DestroyLanguagesDB(); 00172 public: 00173 static const wxLanguageInfo* GetLanguageInfo(int lang); 00174 #endif // __BORLANDC__ 00175 }; 00176 //--------------------------------------------------------------------------- 00177 00178 00179 #endif // INC_LANGUAGE_HPP

Generated on Sun May 30 13:37:45 2004 for wxChecksums by doxygen 1.3.7