Stellarium 0.15.2
StelLocaleMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELLOCALEMGR_HPP_
21 #define _STELLOCALEMGR_HPP_
22 
23 #include "StelTranslator.hpp"
24 #include "StelCore.hpp"
25 
30 {
31 public:
32  StelLocaleMgr();
33  ~StelLocaleMgr();
34 
39  void init();
40 
42  // MESSAGES TRANSLATIONS
48 
52  void setAppLanguage(const QString& newAppLangName, bool refreshAll=true);
53 
55  const StelTranslator& getAppStelTranslator() const;
56 
58  bool isAppRTL() const;
59 
63  QString getSkyLanguage() const;
64 
69  void setSkyLanguage(const QString& newSkyLangName, bool refreshAll=true);
70 
72  const StelTranslator &getSkyTranslator() const;
73 
75  bool isSkyRTL() const;
76 
78  // DATE & TIME LOCALIZATION
87  QString getTimeFormatStr(void) const {return sTimeFormatToString(timeFormat);}
90  void setTimeFormatStr(const QString& tf) {timeFormat=stringToSTimeFormat(tf);}
99  QString getDateFormatStr(void) const {return sDateFormatToString(dateFormat);}
100  void setDateFormatStr(const QString& df) {dateFormat=stringToSDateFormat(df);}
101 
103  QString getQtDateFormatStr(void) const;
104 
107  enum STimeFormat {
111  };
112 
115  enum SDateFormat {
120  };
121 
123  QString getPrintableDateLocal(double JD) const;
124 
126  QString getPrintableTimeLocal(double JD) const;
127 
129  QString getPrintableTimeZoneLocal(double JD) const;
130 
133  QString getISO8601TimeLocal(double JD) const;
134 
140  double getJdFromISO8601TimeLocal(const QString& str, bool* ok) const;
141 
143  static QString countryCodeToString(const QString& countryCode);
145  static QString countryNameToCode(const QString& countryName);
146 
148  static QStringList getAllCountryNames();
149 
150 private:
151  // The translator used for astronomical object naming
152  StelTranslator* skyTranslator;
153  StelCore* core;
154 
155  // Date and time variables
156  STimeFormat timeFormat;
157  SDateFormat dateFormat;
158 
159  // Convert the time format enum to its associated string and reverse
160  STimeFormat stringToSTimeFormat(const QString&) const;
161  QString sTimeFormatToString(STimeFormat) const;
162 
163  // Convert the date format enum to its associated string and reverse
164  SDateFormat stringToSDateFormat(const QString& df) const;
165  QString sDateFormatToString(SDateFormat df) const;
166 
167  static QMap<QString, QString> countryCodeToStringMap;
168 
169  static void generateCountryList();
170 };
171 
172 #endif // _STELLOCALEMGR_HPP_
const StelTranslator & getSkyTranslator() const
Get a reference to the StelTranslator object currently used for sky objects.
const QString & getTrueLocaleName() const
Get true translator locale name.
e.g. "05-07-1998" for July 5th 1998
Class used to translate strings to any language.
Use the system default date format.
e.g. "07-05-1998" for July 5th 1998
bool isAppRTL() const
Get the type (RTL or LTR) of application language currently used for GUI etc.
double getJdFromISO8601TimeLocal(const QString &str, bool *ok) const
Return the JD time for a local time ISO 8601 format that is: Y-m-dTH:M:S, but Y can be a large number...
void setTimeFormatStr(const QString &tf)
Set the time format from a format string.
QString getDateFormatStr(void) const
Get the format string which describes the current date format.
Manage i18n operations such as message translation and date/time localization.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
use the system default format.
SDateFormat
The date display format.
static StelTranslator * globalTranslator
Used as a global translator by the whole app.
static QString countryNameToCode(const QString &countryName)
Convert a countryName to 2 letter country code. Returns "??" if not found.
const StelTranslator & getAppStelTranslator() const
Get the StelTranslator object currently used for global application.
static QString countryCodeToString(const QString &countryCode)
Convert a 2 letter country code to string. Returns empty string if countryCode unknown.
12 hour clock, e.g. "06:22:00 pm"
void setAppLanguage(const QString &newAppLangName, bool refreshAll=true)
Set the application language.
Define some translation macros.
QString getPrintableTimeZoneLocal(double JD) const
Get a localized, formatted string representation of the time zone of a Julian date.
bool isSkyRTL() const
Get the type (RTL or LTR) of language currently used for sky objects.
STimeFormat
The time display format.
QString getTimeFormatStr(void) const
Get the format string which describes the current time format.
QString getPrintableTimeLocal(double JD) const
Get a localized, formatted string representation of the time component of a Julian date...
QString getAppLanguage() const
Get the application language currently used for GUI etc.
void init()
Initialize object.
e.g. "1998-07-05" for July 5th 1998
static QStringList getAllCountryNames()
Return an alphabetically ordered list of all the known country names.
QString getQtDateFormatStr(void) const
Get the format string which describes the current date format (Qt style).
QString getPrintableDateLocal(double JD) const
Get a localized, formatted string representation of the date component of a Julian date...
QString getSkyLanguage() const
Get the language currently used for sky objects.
24 hour clock, e.g. "18:22:00"
void setSkyLanguage(const QString &newSkyLangName, bool refreshAll=true)
Set the sky language and reload the sky object names with the new translation.
QString getISO8601TimeLocal(double JD) const
Return the time in ISO 8601 format that is : Y-m-dTH:M:S.