Core
Class Locale

source: e:\games\UnrealTournament\Core\Classes\Locale.uc
Core.Object
   |
   +--Core.Locale
Direct Known Subclasses:None

class Locale
extends Core.Object

//============================================================================= /// Locale: Locale management class. /// Not yet implemented. /// This is a built-in Unreal class and it shouldn't be modified. //=============================================================================
Variables
 string AMPM[2]
 string DateFormat
 string DaysOfWeek[7]
 int DecimalCount
 Decimal, DecimalCurrency
 string DisplayLanguage
 array EditableTimeFields
 string ISO3Language
 string Months[12]
 int PercentScaler
 PreCurrencySymbol, PostCurrencySymbol
 PrePercent, PostPercent
 localized ShowAMPM
 ThousandsCount, ThousandsCountCurrency
 ThousandsDelimitor, ThousandsDelimitorCurrency
 localized string
 localized string


Function Summary
 int Compare(string A, string B)
     
/// Compare two strings using locale-specific sorting.
 string CurrencyToString(float Currency)
     
/// Convert a float number to a currency string using the locale's formatting instructions.
 string DateToString(long T)
     
// Convert the date to a human-readable string, depending on the current locale.
 string GetDisplayLanguage(string Language)
     
/// Returns the localized, human-readable display name of the ISO 3 language code Language.
native 
 string GetLanguage()
     
/// Returns the currently active language's ISO 3 language code.
native 
 string NumberToString(float Number)
     
/// Convert a float number to a string using the locale's formatting instructions.
 string PercentToString(float Fraction)
     
/// Convert a fraction from 0.0-1.0 to a percentage string.
 bool SetLanguage(string NewLanguage)
     
/// Set the current ISO 3 language. Causes all class' and objects' localized variables to be reloaded.
native 
 string TimeToString(long T, bool Brief, bool Countdown)
     
/// Converts the time to a human-readable string, depending on the current locale.
 string ToLower(string S)
     
/// Convert to locale-specific lowercase.
 string ToUpper(string S)
     
/// Convert to locale-specific uppercase.



Source Code


00001	//=============================================================================
00002	/// Locale: Locale management class.
00003	/// Not yet implemented.
00004	/// This is a built-in Unreal class and it shouldn't be modified.
00005	//=============================================================================
00006	class Locale
00007		expands Object
00008		transient;
00009	
00010	/*
00011	//
00012	// Information about this locale.
00013	//
00014	
00015	//!!System.GetLocale( language, variant, local )
00016	///@reference: !!look at java getISO3Language for std 3-char language abbreviations
00017	var const string ISO3Language;
00018	var const localized string DisplayLanguage;
00019	
00020	//
00021	// Locale language support.
00022	//
00023	
00024	/// Returns the currently active language's ISO 3 language code.
00025	native function string GetLanguage();
00026	
00027	/// Returns the localized, human-readable display name of the ISO 3 language code Language.
00028	native function string GetDisplayLanguage( string Language );
00029	
00030	/// Set the current ISO 3 language. Causes all class' and objects' localized variables to be reloaded.
00031	native function bool SetLanguage( string NewLanguage );
00032	
00033	//
00034	// Locale string processing.
00035	//
00036	
00037	/// Convert to locale-specific uppercase.
00038	function string ToUpper( string S );
00039	
00040	/// Convert to locale-specific lowercase.
00041	function string ToLower( string S );
00042	
00043	/// Compare two strings using locale-specific sorting.
00044	function int Compare( string A, string B );
00045	
00046	//
00047	// Locale number and currency handling.
00048	//
00049	
00050	/// Leading and trailing percentage symbols.
00051	var const localized string PrePercent, PostPercent;
00052	
00053	/// Leading and trailing currency symbols.
00054	var const localized string PreCurrencySymbol, PostCurrencySymbol;
00055	
00056	/// Percentage scale, i.e. 100 for 100%.
00057	var const localized int PercentScaler;
00058	
00059	/// Number of digits between "thousands" delimitor.
00060	var const localized int ThousandsCount, ThousandsCountCurrency;
00061	
00062	/// Positive and negative currency indicators.
00063	var const localized string
00064		PrePositiveCurrency, PostPositiveCurrency,
00065		PreNegativeCurrency, PostNegativeCurrency;
00066	
00067	// Thousands delimitor.
00068	var const localized string ThousandsDelimitor, ThousandsDelimitorCurrency;
00069	
00070	// Decimal point.
00071	var const localized string Decimal, DecimalCurrency;
00072	
00073	// Decimal count.
00074	var const localized int DecimalCount;
00075	
00076	/// Convert a float number to a string using the locale's formatting instructions.
00077	function string NumberToString( float Number );
00078	
00079	/// Convert a float number to a currency string using the locale's formatting instructions.
00080	function string CurrencyToString( float Currency );
00081	
00082	/// Convert a fraction from 0.0-1.0 to a percentage string.
00083	function string PercentToString( float Fraction )
00084	{
00085		return PrePercent $ int(Fraction * PercentScaler) $ PostPercent;
00086	}
00087	
00088	//
00089	// Locale date and time support.
00090	//
00091	
00092	/// Human readable names of months.
00093	var const localized string Months[12];
00094	
00095	/// Human readable names of days-of-week.
00096	var const localized string DaysOfWeek[7];
00097	
00098	/// Human-readable AM/PM.
00099	var const localized string AMPM[2];
00100	
00101	/// Whether to display AM/PM, otherwise uses 24-hour notation.
00102	var const localized ShowAMPM;
00103	
00104	/// List of TimeToMap fields which should be exposed for editing in this locale.
00105	var const localized array<string> EditableTimeFields;
00106	
00107	/// Format string for generating human-readable time in AM/PM and 24-hour formats; 
00108	/// may be ignored by Locale subclasses who display times using a different calendar,
00109	/// for example Chinese.
00110	var const localized string
00111		TimeFormatAMPM, TimeFormat24Hour,
00112		BriefTimeFormatAMPM, BriefTimeFormat24Hour,
00113		CountdownTimeFormat;
00114	
00115	/// Format string for generating human-readable dates.
00116	var const localized string DateFormat;
00117	
00118	/// Return a map containing time parameters suitable for formatting.
00119	function map<string,string> DateTimeToMap( long T )
00120	{
00121		local map<string,string> M;
00122		M.Set("Year",       Time.GetYear(T));
00123		M.Set("Month",      Time.GetMonth(T));
00124		M.Set("MonthName",  Months(Time.GetMonth(T)));
00125		M.Set("Day",        Time.GetDay(T));
00126		M.Set("DayName",    DaysOfWeek(Time.GetDay(T)));
00127		M.Set("Hour24",     Time.GetHour(T));
00128		M.Set("Hour12",     Time.GetHour(T)%12);
00129		M.Set("AMPM",       AMPM(Time.GetHour(T)/12);
00130		M.Set("Minute",     Time.GetMinute(T));
00131		M.Set("Second",     Time.GetSecond(T));
00132		M.Set("MSec",       Time.GetMSec(T));
00133		M.Set("USec",       Time.GetUSec(T));
00134		M.Set("NSec",       Time.GetNSec(T));
00135		return M;
00136	}
00137	
00138	/// Convert a map of TimeToMap key-values to a time; returns true if successful.
00139	function bool MapToDateTime( map<string,string> Map, out long T )
00140	{
00141		//!!
00142	}
00143	
00144	/// Converts the time to a human-readable string, depending on the current locale.
00145	function string TimeToString( long T, bool Brief, bool Countdown )
00146	{
00147		local string S;
00148		if( Brief )
00149		{
00150			if( ShowAMPM ) S = BriefTimeFormatAMPM;
00151			else           S = BriefTimeFormat24Hour, 
00152		}
00153		else if( !Countdown )
00154		{
00155			if( ShowAMPM ) S = TimeFormatAMPM;
00156			else           S = TimeFormat24Hour, 
00157		}
00158		else
00159		{
00160			S = CountdownTimeFormat;
00161		}
00162		return string.Format( S, DateTimeToMap(T) );
00163	}
00164	
00165	// Convert the date to a human-readable string, depending on the current locale.
00166	function string DateToString( long T )
00167	{
00168		return string.Format( DateFormat, DateTimeToMap(T) );
00169	}
00170	
00171	_defaultproperties
00172	{
00173		Months(0)=January
00174		Months(1)=February
00175		Months(2)=March
00176		Months(3)=April
00177		Months(4)=May
00178		Months(5)=June
00179		Months(6)=July
00180		Months(7)=August
00181		Months(8)=September
00182		Months(9)=October
00183		Months(10)=November
00184		Months(11)=December
00185		DaysOfWeek(0)=Sunday
00186		DaysOfWeek(1)=Monday
00187		DaysOfWeek(2)=Tuesday
00188		DaysOfWeek(3)=Wednesday
00189		DaysOfWeek(4)=Thursday
00190		DaysOfWeek(5)=Friday
00191		DaysOfWeek(6)=Saturday
00192		AMPM(0)=AM
00193		AMPM(1)=PM
00194		TimeFormatAMPM=%Hour12:02%.%Minute:02%.%Seconds:02% %AMPM%
00195		TimeFormat24Hour=%Hour24:02%.%Minute:02%.%Seconds:02%
00196		BriefTimeFormatAMPM=%Hour12:02%.%Minute:02% %AMPM%
00197		BriefTimeFormat24Hour=%Hour24:02%.%Minute:02%
00198		CountdownTimeFormat=%Hour24:02%.%Minute:02%.%Seconds:02%
00199		DateFormat=%DayName% %MonthName% %Day%, %Year%
00200		EditableTimeFields(0)=Year
00201		EditableTimeFields(1)=Month
00202		EditableTimeFields(2)=Day
00203		EditableTimeFields(3)=Hour12
00204		EditableTimeFields(4)=AMPM
00205		EditableTimeFields(5)=Minute
00206		EditableTimeFields(6)=Second
00207		PreCurrencySymbol=$
00208		PostCurrencySymbol=
00209		PrePercent=
00210		PostPercent=%
00211		PercentScaler=100
00212		ThousandsCount=1000
00213		ThousandsCountCurrency=1000
00214		ThousandsDelimitor=","
00215		ThousandsDelimitorCurrency=","
00216		Decimal="."
00217		DecimalCurrency="."
00218		PrePositiveCurrency=
00219		PostPositiveCurrency=
00220		PreNegativeCurrency=-
00221		PostNegativeCurrency=
00222		DecimalCount=2
00223	}
00224	*/
00225	
00226	defaultproperties
00227	{
00228	}

End Source Code