3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "settings/ISettingCallback.h"
23 #include "utils/StdString.h"
30 #endif // GetDateFormat
33 #endif // GetTimeFormat
34 #endif // TARGET_WINDOWS
38 class CLangInfo : public ISettingCallback
44 virtual void OnSettingChanged(const CSetting *setting);
46 bool Load(const std::string& strFileName, bool onlyCheckLanguage = false);
48 CStdString GetGuiCharSet() const;
49 CStdString GetSubtitleCharSet() const;
51 // three char language code (not win32 specific)
52 const CStdString& GetLanguageCode() const { return m_languageCodeGeneral; }
54 bool SetLanguage(const std::string &strLanguage);
56 const CStdString& GetAudioLanguage() const;
57 // language can either be a two char language code as defined in ISO639
58 // or a three char language code
59 // or a language name in english (as used by XBMC)
60 void SetAudioLanguage(const CStdString &language);
62 // three char language code (not win32 specific)
63 const CStdString& GetSubtitleLanguage() const;
64 // language can either be a two char language code as defined in ISO639
65 // or a three char language code
66 // or a language name in english (as used by XBMC)
67 void SetSubtitleLanguage(const CStdString &language);
69 const std::string GetDVDMenuLanguage() const;
70 const std::string GetDVDAudioLanguage() const;
71 const std::string GetDVDSubtitleLanguage() const;
72 const CStdString& GetTimeZone() const;
74 const CStdString& GetRegionLocale() const;
75 const std::string GetLanguageLocale(bool twochar = false) const;
77 bool ForceUnicodeFont() const { return m_currentRegion->m_forceUnicodeFont; }
79 const CStdString& GetDateFormat(bool bLongDate=false) const;
81 typedef enum _MERIDIEM_SYMBOL
88 const CStdString& GetTimeFormat() const;
89 const CStdString& GetMeridiemSymbol(MERIDIEM_SYMBOL symbol) const;
91 typedef enum _TEMP_UNIT
93 TEMP_UNIT_FAHRENHEIT=0,
103 const CStdString& GetTempUnitString() const;
104 CLangInfo::TEMP_UNIT GetTempUnit() const;
107 typedef enum _SPEED_UNIT
109 SPEED_UNIT_KMH=0, // kilemetre per hour
110 SPEED_UNIT_MPMIN, // metres per minute
111 SPEED_UNIT_MPS, // metres per second
112 SPEED_UNIT_FTH, // feet per hour
113 SPEED_UNIT_FTMIN, // feet per minute
114 SPEED_UNIT_FTS, // feet per second
115 SPEED_UNIT_MPH, // miles per hour
116 SPEED_UNIT_KTS, // knots
117 SPEED_UNIT_BEAUFORT, // beaufort
118 SPEED_UNIT_INCHPS, // inch per second
119 SPEED_UNIT_YARDPS, // yard per second
120 SPEED_UNIT_FPF // Furlong per Fortnight
123 const CStdString& GetSpeedUnitString() const;
124 CLangInfo::SPEED_UNIT GetSpeedUnit() const;
126 void GetRegionNames(CStdStringArray& array);
127 void SetCurrentRegion(const CStdString& strName);
128 const CStdString& GetCurrentRegion() const;
130 static void LoadTokens(const TiXmlNode* pTokens, std::vector<CStdString>& vecTokens);
132 static void SettingOptionsLanguagesFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t);
133 static void SettingOptionsStreamLanguagesFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t);
134 static void SettingOptionsRegionsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t);
142 CRegion(const CRegion& region);
146 void SetTempUnit(const CStdString& strUnit);
147 void SetSpeedUnit(const CStdString& strUnit);
148 void SetTimeZone(const CStdString& strTimeZone);
149 void SetGlobalLocale();
150 CStdString m_strGuiCharSet;
151 CStdString m_strSubtitleCharSet;
152 CStdString m_strDVDMenuLanguage;
153 CStdString m_strDVDAudioLanguage;
154 CStdString m_strDVDSubtitleLanguage;
155 CStdString m_strLangLocaleName;
156 std::string m_strLangLocaleCodeTwoChar;
157 CStdString m_strRegionLocaleName;
158 bool m_forceUnicodeFont;
159 CStdString m_strName;
160 CStdString m_strDateFormatLong;
161 CStdString m_strDateFormatShort;
162 CStdString m_strTimeFormat;
163 CStdString m_strMeridiemSymbols[MERIDIEM_SYMBOL_MAX];
164 CStdString m_strTimeZone;
166 TEMP_UNIT m_tempUnit;
167 SPEED_UNIT m_speedUnit;
171 typedef std::map<CStdString, CRegion> MAPREGIONS;
172 typedef std::map<CStdString, CRegion>::iterator ITMAPREGIONS;
173 typedef std::pair<CStdString, CRegion> PAIR_REGIONS;
174 MAPREGIONS m_regions;
175 CRegion* m_currentRegion; // points to the current region
176 CRegion m_defaultRegion; // default, will be used if no region available via langinfo.xml
178 CStdString m_audioLanguage;
179 CStdString m_subtitleLanguage;
180 // this is the general (not win32-specific) three char language code
181 CStdString m_languageCodeGeneral;
185 extern CLangInfo g_langInfo;