Android Programming Press on the image to return to the main documentation page.

AHLocale

Written by Markus Stipp

List of types:

AHDateTime
AHLocale
AHTranslator

AHDateTime

With the AHDateTime object you can format and parse date and time strings.

The B4A builtin DateTime object always uses localized format strings so it is
not possible to parse something like "2011/05/19 01:45 PM" on a german device
because "PM" is "nachm." there. You can Initialize the AHDateTime object with
any locale you want and so you are totally free on date formats.

Events:

None

Members:


  Format (ticks As LongAs String

  Initialize

  Initialize2 (locale As AHLocale)

  InitializeUS

  Lenient As Boolean

  Parse (date As StringAs Long

  Pattern As String

Members description:

Format (ticks As LongAs String
Formats the specified ticks value to a string with the specified pattern.
Initialize
Initializes the AHDateTime object with the default locale.
Initialize2 (locale As AHLocale)
Initializes the AHDateTime object with the given AHLocale object
InitializeUS
Initializes the AHDateTime object with the en_US locale.
Lenient As Boolean
If you set this to true the parser is not very strict on his date format.
Parse (date As StringAs Long
Parses the specified string and returns a tick value.

Throws an exception if the string can not be parsed.
Pattern As String
Sets or gets the Date/Time pattern

Default pattern is: yyyy-MM-dd HH:mm:ss

For allowed placeholders look here:
SimpleDateFormat

AHLocale

The AHLocale object allows you to access many locale aware values such as
localized month names, day names or currency symbols.

There are also methods to find out which locales are available on your device
or which languages and countries can be used.

Events:

None

Members:


  AmPmStrings() As String  [read only]

  AvailableLocales As List  [read only]

  Country As String  [read only]

  CurrencyCode As String  [read only]

  CurrencyFractionDigits As Int  [read only]

  CurrencySymbol As String  [read only]

  DisplayCountry As String  [read only]

  DisplayLanguage As String  [read only]

  DisplayName As String  [read only]

  EnglishCountry As String  [read only]

  EnglishLanguage As String  [read only]

  EnglishName As String  [read only]

  FirstDayOfWeek As Int  [read only]

  Initialize

  Initialize2 (language As String)

  Initialize3 (language As String, country As String)

  Initialized As Boolean  [read only]

  InitializeUS

  ISO3Country As String  [read only]

  ISO3Language As String  [read only]

  ISOCode As String  [read only]

  ISOCountries() As String  [read only]

  ISOLanguages() As String  [read only]

  Language As String  [read only]

  Months() As String  [read only]

  myLocale As java.util.Locale

  ShortMonths() As String  [read only]

  ShortWeekDays() As String  [read only]

  WeekDays() As String  [read only]

Members description:

AmPmStrings() As String  [read only]
Returns the array of strings which represent AM and PM.
AvailableLocales As List  [read only]
Returns the system's installed locales. These are returned as a B4A List of AHLocale Objects.
There are only locales in this list which have a non empty country and language.
Country As String  [read only]
Returns the country/region code for this locale, which will either be the
empty string or an uppercase ISO 3166 2-letter code.
CurrencyCode As String  [read only]
Returns this currency's ISO 4217 currency code.
CurrencyFractionDigits As Int  [read only]
Returns the default number of fraction digits for this currency.
CurrencySymbol As String  [read only]
Returns the localized currency symbol for this currency in locale.
DisplayCountry As String  [read only]
Returns the name of this locale's country, localized to locale. Returns
the empty string if this locale does not correspond to a specific country
DisplayLanguage As String  [read only]
Returns the name of this locale's language, localized to locale. If the
language name is unknown, the language code is returned.
DisplayName As String  [read only]
Returns this locale's language name, country name, and variant, localized
to locale. The exact output form depends on whether this locale
corresponds to a specific language, country and variant, such as:
English, English (United States), English (United States,Computer),
anglais (?tats-Unis), anglais (?tats-Unis,informatique).
EnglishCountry As String  [read only]
Returns the name of this locale's country in english. Returns
the empty string if this locale does not correspond to a specific country
EnglishLanguage As String  [read only]
Returns the name of this locale's language in english. If the
language name is unknown, the language code is returned.
EnglishName As String  [read only]
Returns this locale's language name, country name, and variant in english.
The exact output form depends on whether this locale
corresponds to a specific language, country and variant, such as:
English, English (United States), English (United States,Computer),
anglais (?tats-Unis), anglais (?tats-Unis,informatique).
FirstDayOfWeek As Int  [read only]
Gets the first day of the week
Initialize
Initializes the AHLocale object with the default locale.
Initialize2 (language As String)
Initializes the AHLocale object using the specified language.
Initialize3 (language As String, country As String)
Initializes the AHLocale object using the specified language and country.
Initialized As Boolean  [read only]
Returns if the object is initialized
InitializeUS
Initializes the AHLocale Object with en_US locale. This locale is
available on every device.
ISO3Country As String  [read only]
Gets the three letter ISO country code which corresponds to the country
code for this Locale.
ISO3Language As String  [read only]
Gets the three letter ISO language code which corresponds to the language
code for this Locale.
ISOCode As String  [read only]
Returns the ISO Code for this Locale such as en_US or de_DE
ISOCountries() As String  [read only]
Gets the list of two letter ISO country codes which can be used as the
country code for a Locale.
ISOLanguages() As String  [read only]
Gets the list of two letter ISO language codes which can be used as the
language code for a Locale.
Language As String  [read only]
Gets the language code for this Locale or the empty string if no language
was set.
Months() As String  [read only]
Returns the array of strings containing the full names of the months.
myLocale As java.util.Locale
ShortMonths() As String  [read only]
Returns the array of strings containing the abbreviated names of the months.
ShortWeekDays() As String  [read only]
Returns the array of strings containing the abbreviated names of the days of the week.
WeekDays() As String  [read only]
Returns the array of strings containing the full names of the days of the week.

AHTranslator

With the Translator object you can make your programs support multiple
languages. It is very easy to create translations for your program and use
them.

Translation files have the following name convention:
[basename]_[language].lng

The format is a standard Java properties file. Special characters should be
converted to unicode sequences.

The translator object holds two Map Objects for the translations. One for the
existing translations in the language file and one for missing translations
in the language file. When you call GetText() with a string that is not in
the translation file then it will be added to the missing translations Map.

Events:

None

Members:


  CurrentFile As String  [read only]

  CurrentLanguage As String  [read only]

  GetText (text As StringAs String

  GetText2 (text As String, params As ListAs String

  Initialize (dir As String, basename As String)

  Initialize2 (dir As String, basename As String, language As String)

  MissingTranslationMap As Map  [read only]

  TranslationMap As Map

  WriteTranslation (dir As String, filename As String)

Members description:

CurrentFile As String  [read only]
Returns current file name of language file
CurrentLanguage As String  [read only]
Returns current Language code
GetText (text As StringAs String
Searches for the text in the translation table. If a translation is
available it will be returned. If no translation is available the text is
added to the missing translation table and the original text is returned.
So you can write your whole program in a default language. If a
translation is available it will be used, if not, the text will be
returned in the default language.
GetText2 (text As String, params As ListAs String
Searches for the text in the translation table and returns the translated
text.

You can use Placeholders in the form of {1} {2} etc. which will be
replaced with the content of the second parameter. {1} will be replaced
with the first item in the Array/List, {2} with the second one and so on.
Initialize (dir As String, basename As String)
Initializes a translation object with the device language. Tries to read a
translation file with the following name convention: basename_language.lng
Initialize2 (dir As String, basename As String, language As String)
Initializes a translation object with the given language. Tries to read a
translation file with the following name convention: basename_language.lng
MissingTranslationMap As Map  [read only]
Returns a Map object with all text phrases which are missing in the
translation file.
TranslationMap As Map
Returns a Map object with the current translations
WriteTranslation (dir As String, filename As String)
Writes two files to the specified dir. The current translation Map is
written to [filename]_[language].lng and the missing translation Map is
written to [filename]_miss_[language].lng
Top