Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
jm::I18nBundle Class Reference

This class provides a central resource to translate an application into the local language for the user. More...

Inheritance diagram for jm::I18nBundle:
jm::Preferences jm::Hashtable jm::Object

Public Member Functions

 I18nBundle (const String &language)
 Constructor.
 
void appendMo (Stream *stream)
 This method reads a *.mo file and adds the content to this bundle.
 
String translate (const String &key) const
 
- Public Member Functions inherited from jm::Preferences
 Preferences ()
 Constructor.
 
 ~Preferences () override
 Destructor. Deletes all entries in the hashtable.
 
void load (File file)
 This method reads the data from the file.
 
void save (File file)
 This method writes the preferences to the file.
 
bool hasValue (const String &key) const
 Check if the property is present.
 
void setValue (const String &key, const String &value)
 Sets the property. Essentially calls the Put() method of Hashtable, but ensures that strings are used.
 
void setValue (const String &key, int64 value)
 Sets the property. Essentially calls the Put() method of Hashtable, but ensures that strings are used.
 
void setValue (const String &key, double value)
 Sets the property. Essentially calls the Put() method of Hashtable, but ensures that strings are used.
 
void setValue (const String &key, bool value)
 Sets the property. Essentially calls the Put() method of Hashtable, but ensures that strings are used.
 
String value (const String &key) const
 Returns the desired property.
 
String value (const String &key, const String &defaultValue) const
 Returns the desired property.
 
int64 valueInt (const String &key, int64 defaultValue) const
 Returns the desired property.
 
double valueDouble (const String &key, double defaultValue) const
 Returns the desired property.
 
bool valueBool (const String &key, bool defaultValue) const
 Returns the desired property.
 
- Public Member Functions inherited from jm::Hashtable
 Hashtable () noexcept
 Default constructor for the Hashtable class.
 
 ~Hashtable () noexcept override
 Destructor for the Hashtable class.
 
void * put (String key, void *value) noexcept
 This method inserts a new element into the hash table.
 
void * get (const String &key) const noexcept
 This method returns the object associated with the specified key.
 
void * remove (const String &key) noexcept
 This method removes the object associated with the specified key.
 
size_t size () const noexcept
 Returns the number of entries in this hash table.
 
bool isEmpty () const noexcept
 This method returns true if the hashtable is empty.
 
bool containsKey (const String &key) const noexcept
 This method returns true if an object is associated with the specified key.
 
bool containsValue (void *value) const noexcept
 This method returns true if the hashtable contains an object associated with the specified value.
 
Iteratorkeys () noexcept
 This method returns an object of the "Iterator" class that iterates through the keys of this table.
 
Iteratorvalues () noexcept
 This method returns an object of the "Iterator" class that iterates through the values of this table.
 
void clear () noexcept
 This method removes all elements from the Hashtable.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Static Public Member Functions

static I18nBundlegetDefault ()
 returns the application default translation
 
static void initDefault ()
 This method is called on start-up from jm::System to initialise the default language. The developer usually do not need to call this.
 
static void quitDefault ()
 This method is called on shutdown from jm::System to free the default language.
 
static jm::Resource transFileByBundleId (const String &filename, const String &language)
 Try to examine the language file for given bundle-id.
 

Additional Inherited Members

- Protected Member Functions inherited from jm::Hashtable
void rehash () noexcept
 This method increases the capacity of the Hashtable.
 

Detailed Description

This class provides a central resource to translate an application into the local language for the user.

Constructor & Destructor Documentation

◆ I18nBundle()

jm::I18nBundle::I18nBundle ( const String language)
explicit

Constructor.

Parameters
languageLanguage String in form: "de-DE"

Member Function Documentation

◆ appendMo()

void jm::I18nBundle::appendMo ( Stream stream)

This method reads a *.mo file and adds the content to this bundle.

Parameters
streamThe mo resource (file, resource etc.).

◆ getDefault()

static I18nBundle * jm::I18nBundle::getDefault ( )
static

returns the application default translation

◆ initDefault()

static void jm::I18nBundle::initDefault ( )
static

This method is called on start-up from jm::System to initialise the default language. The developer usually do not need to call this.

◆ quitDefault()

static void jm::I18nBundle::quitDefault ( )
static

This method is called on shutdown from jm::System to free the default language.

◆ transFileByBundleId()

static jm::Resource jm::I18nBundle::transFileByBundleId ( const String filename,
const String language 
)
static

Try to examine the language file for given bundle-id.

◆ translate()

String jm::I18nBundle::translate ( const String key) const