Stellarium  0.20.4
Public Types | Public Member Functions | Static Public Member Functions
StelLocaleMgr Class Reference

Manage i18n operations such as message translation and date/time localization. More...

#include <StelLocaleMgr.hpp>

Public Types

enum  STimeFormat { STimeSystemDefault, STime24h, STime12h }
 The time display format. More...
 
enum  SDateFormat {
  SDateSystemDefault, SDateMMDDYYYY, SDateDDMMYYYY, SDateYYYYMMDD,
  SDateWWMMDDYYYY, SDateWWDDMMYYYY, SDateWWYYYYMMDD
}
 The date display format. More...
 

Public Member Functions

void init ()
 Initialize object. More...
 
QString getAppLanguage () const
 Get the application language currently used for GUI etc. More...
 
void setAppLanguage (const QString &newAppLangName, bool refreshAll=true)
 Set the application language. More...
 
const StelTranslatorgetAppStelTranslator () const
 Get the StelTranslator object currently used for global application.
 
bool isAppRTL () const
 Get the type (RTL or LTR) of application language currently used for GUI etc.
 
QString getSkyLanguage () const
 Get the language currently used for sky objects. More...
 
void setSkyLanguage (const QString &newSkyLangName, bool refreshAll=true)
 Set the sky language and reload the sky object names with the new translation. More...
 
const StelTranslatorgetSkyTranslator () const
 Get a reference to the StelTranslator object currently used for sky objects.
 
const StelTranslatorgetPlanetaryFeaturesTranslator () const
 Get a reference to the StelTranslator object currently used for planetary features.
 
const StelTranslatorgetScriptsTranslator () const
 Get a reference to the StelTranslator object currently used for scripts.
 
bool isSkyRTL () const
 Get the type (RTL or LTR) of language currently used for sky objects.
 
QString getTimeFormatStr (void) const
 Get the format string which describes the current time format. More...
 
void setTimeFormatStr (const QString &tf)
 Set the time format from a format string. More...
 
QString getDateFormatStr (void) const
 Get the format string which describes the current date format. More...
 
void setDateFormatStr (const QString &df)
 
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 getPrintableTimeLocal (double JD) const
 Get a localized, formatted string representation of the time component of a Julian date.
 
QString getPrintableTimeZoneLocal (double JD) const
 Get a localized, formatted string representation of the time zone of a Julian date.
 
QString getISO8601TimeLocal (double JD) const
 Return the time in ISO 8601 format that is : Y-m-dTH:M:S. More...
 
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 with sign, and Y can be zero. More...
 

Static Public Member Functions

static QString countryCodeToString (const QString &countryCode)
 Convert a 2 letter country code to string. Returns empty string if countryCode unknown.
 
static QString countryNameToCode (const QString &countryName)
 Convert a countryName to 2 letter country code. Returns "??" if not found.
 
static QStringList getAllCountryNames ()
 Return an alphabetically ordered list of all the known country names.
 
static QString shortDayName (int weekday)
 Returns the short name of the weekday [0=Sunday, 1=Monday..6]; weekday mod 7)
 
static QString longDayName (int weekday)
 Returns the long name of the weekday ([0..6]; weekday mod 7)
 
static QString shortMonthName (int month)
 Returns the short name of the month [1..12].
 
static QString longMonthName (int month)
 Returns the long name of the month [1..12].
 
static QString longGenitiveMonthName (int month)
 Returns the genitive long name of the month [1..12].
 
static QString romanMonthName (int month)
 Returns the Roman name (a number) of the month [1..12].
 

Detailed Description

Author
Fabien Chereau

Member Enumeration Documentation

◆ SDateFormat

Enumerator
SDateSystemDefault 

Use the system default date format.

SDateMMDDYYYY 

e.g. "07-05-1998" for July 5th 1998

SDateDDMMYYYY 

e.g. "05-07-1998" for July 5th 1998

SDateYYYYMMDD 

e.g. "1998-07-05" for July 5th 1998

SDateWWMMDDYYYY 

e.g. "Sun, 07-05-1998" for Sunday, July 5th 1998

SDateWWDDMMYYYY 

e.g. "Sun, 05-07-1998" for Sunday, July 5th 1998

SDateWWYYYYMMDD 

e.g. "Sun, 1998-07-05" for Sunday, July 5th 1998

◆ STimeFormat

Enumerator
STimeSystemDefault 

use the system default format.

STime24h 

24 hour clock, e.g. "18:22:00"

STime12h 

12 hour clock, e.g. "06:22:00 pm"

Member Function Documentation

◆ getAppLanguage()

QString StelLocaleMgr::getAppLanguage ( ) const
inline

This function has no permanent effect on the global locale.

Returns
the abbreviated name of the language (e.g "fr").

◆ getDateFormatStr()

QString StelLocaleMgr::getDateFormatStr ( void  ) const
inline

Valid values:

  • "mmddyyyy"
  • "ddmmyyyy"
  • "system_default"
  • "yyyymmdd"

These values correspond to the similarly named values in the SDateFormat enum.

◆ getISO8601TimeLocal()

QString StelLocaleMgr::getISO8601TimeLocal ( double  JD) const
Parameters
JDthe time and date expressed as a Julian date value.

◆ getJdFromISO8601TimeLocal()

double StelLocaleMgr::getJdFromISO8601TimeLocal ( const QString &  str,
bool *  ok 
) const
Parameters
strthe local time in ISO 8601 format.
okset to false if the string was an invalid date.

◆ getSkyLanguage()

QString StelLocaleMgr::getSkyLanguage ( ) const

This function has no permanent effect on the global locale.

Returns
the name of the language (e.g fr).

◆ getTimeFormatStr()

QString StelLocaleMgr::getTimeFormatStr ( void  ) const
inline

Valid values are:

  • "system_default"
  • "24h"
  • "12h"

These values correspond to the similarly named values in the STimeFormat enum.

◆ init()

void StelLocaleMgr::init ( )

This process includes:

  • Setting the sky and application languages
  • Setting the time and date formats
  • Setting up the time zone

◆ setAppLanguage()

void StelLocaleMgr::setAppLanguage ( const QString &  newAppLangName,
bool  refreshAll = true 
)

This applies to GUI etc. This function has no permanent effect on the global locale.

Parameters
newAppLangNamethe abbreviated name of the language (e.g fr).

◆ setSkyLanguage()

void StelLocaleMgr::setSkyLanguage ( const QString &  newSkyLangName,
bool  refreshAll = true 
)

This function has no permanent effect on the global locale.

Parameters
newSkyLangNameThe abbreviated name of the locale (e.g fr) to use for sky object labels.

◆ setTimeFormatStr()

void StelLocaleMgr::setTimeFormatStr ( const QString &  tf)
inline
Parameters
tfvalues are the same as the return values for getTimeFormatStr().