[droid] Do not show any ui if pre-checks are OK
[vuplus_xbmc] / xbmc / LangInfo.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2012 Team XBMC
4  *      http://www.xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 #include "utils/StdString.h"
23
24 #include <map>
25
26 class TiXmlNode;
27
28 class CLangInfo
29 {
30 public:
31   CLangInfo();
32   virtual ~CLangInfo();
33
34   bool Load(const CStdString& strFileName);
35
36   CStdString GetGuiCharSet() const;
37   CStdString GetSubtitleCharSet() const;
38
39   // three char language code (not win32 specific)
40   const CStdString& GetLanguageCode() const { return m_languageCodeGeneral; }
41
42   const CStdString& GetAudioLanguage() const;
43   // language can either be a two char language code as defined in ISO639
44   // or a three char language code
45   // or a language name in english (as used by XBMC)
46   void SetAudioLanguage(const CStdString &language);
47   
48   // three char language code (not win32 specific)
49   const CStdString& GetSubtitleLanguage() const;
50   // language can either be a two char language code as defined in ISO639
51   // or a three char language code
52   // or a language name in english (as used by XBMC)
53   void SetSubtitleLanguage(const CStdString &language);
54
55   const CStdString& GetDVDMenuLanguage() const;
56   const CStdString& GetDVDAudioLanguage() const;
57   const CStdString& GetDVDSubtitleLanguage() const;
58   const CStdString& GetTimeZone() const;
59
60   const CStdString& GetRegionLocale() const;
61   const CStdString& GetLanguageLocale() const;
62
63   bool ForceUnicodeFont() const { return m_currentRegion->m_forceUnicodeFont; }
64
65   const CStdString& GetDateFormat(bool bLongDate=false) const;
66
67   typedef enum _MERIDIEM_SYMBOL
68   {
69     MERIDIEM_SYMBOL_PM=0,
70     MERIDIEM_SYMBOL_AM,
71     MERIDIEM_SYMBOL_MAX
72   } MERIDIEM_SYMBOL;
73
74   const CStdString& GetTimeFormat() const;
75   const CStdString& GetMeridiemSymbol(MERIDIEM_SYMBOL symbol) const;
76
77   typedef enum _TEMP_UNIT
78   {
79     TEMP_UNIT_FAHRENHEIT=0,
80     TEMP_UNIT_KELVIN,
81     TEMP_UNIT_CELSIUS,
82     TEMP_UNIT_REAUMUR,
83     TEMP_UNIT_RANKINE,
84     TEMP_UNIT_ROMER,
85     TEMP_UNIT_DELISLE,
86     TEMP_UNIT_NEWTON
87   } TEMP_UNIT;
88
89   const CStdString& GetTempUnitString() const;
90   CLangInfo::TEMP_UNIT GetTempUnit() const;
91
92
93   typedef enum _SPEED_UNIT
94   {
95     SPEED_UNIT_KMH=0, // kilemetre per hour
96     SPEED_UNIT_MPMIN, // metres per minute
97     SPEED_UNIT_MPS, // metres per second
98     SPEED_UNIT_FTH, // feet per hour
99     SPEED_UNIT_FTMIN, // feet per minute
100     SPEED_UNIT_FTS, // feet per second
101     SPEED_UNIT_MPH, // miles per hour
102     SPEED_UNIT_KTS, // knots
103     SPEED_UNIT_BEAUFORT, // beaufort
104     SPEED_UNIT_INCHPS, // inch per second
105     SPEED_UNIT_YARDPS, // yard per second
106     SPEED_UNIT_FPF // Furlong per Fortnight
107   } SPEED_UNIT;
108
109   const CStdString& GetSpeedUnitString() const;
110   CLangInfo::SPEED_UNIT GetSpeedUnit() const;
111
112   void GetRegionNames(CStdStringArray& array);
113   void SetCurrentRegion(const CStdString& strName);
114   const CStdString& GetCurrentRegion() const;
115
116   static void LoadTokens(const TiXmlNode* pTokens, std::vector<CStdString>& vecTokens);
117 protected:
118   void SetDefaults();
119
120 protected:
121
122   class CRegion
123   {
124   public:
125     CRegion(const CRegion& region);
126     CRegion();
127     virtual ~CRegion();
128     void SetDefaults();
129     void SetTempUnit(const CStdString& strUnit);
130     void SetSpeedUnit(const CStdString& strUnit);
131     void SetTimeZone(const CStdString& strTimeZone);
132     void SetGlobalLocale();
133     CStdString m_strGuiCharSet;
134     CStdString m_strSubtitleCharSet;
135     CStdString m_strDVDMenuLanguage;
136     CStdString m_strDVDAudioLanguage;
137     CStdString m_strDVDSubtitleLanguage;
138     CStdString m_strLangLocaleName;
139     CStdString m_strRegionLocaleName;
140     bool m_forceUnicodeFont;
141     CStdString m_strName;
142     CStdString m_strDateFormatLong;
143     CStdString m_strDateFormatShort;
144     CStdString m_strTimeFormat;
145     CStdString m_strMeridiemSymbols[MERIDIEM_SYMBOL_MAX];
146     CStdString m_strTimeZone;
147
148     TEMP_UNIT m_tempUnit;
149     SPEED_UNIT m_speedUnit;
150   };
151
152
153   typedef std::map<CStdString, CRegion> MAPREGIONS;
154   typedef std::map<CStdString, CRegion>::iterator ITMAPREGIONS;
155   typedef std::pair<CStdString, CRegion> PAIR_REGIONS;
156   MAPREGIONS m_regions;
157   CRegion* m_currentRegion; // points to the current region
158   CRegion m_defaultRegion; // default, will be used if no region available via langinfo.xml
159
160   CStdString m_audioLanguage;
161   CStdString m_subtitleLanguage;
162   // this is the general (not win32-specific) three char language code
163   CStdString m_languageCodeGeneral;
164 };
165
166
167 extern CLangInfo g_langInfo;