Siegfried Locale Library Developer Guide

Quick reference

Alphabetically ordered quick reference of all library functions.

AppID()

Return the application identification of the program.
Usage: const char *add_id;
app_id = AppID();
Parameter: -
Returns: app_id Pointer to a string, the application ID set by SetDefaultText()
Comment: Every application set it's own unique identifaction. The ID is included by all "locale" files. Only those files would be loaded that have the same ID as returned by the funciton.

GetInstance()

Get access to the "locale" data.
Usage: SFLocale *lang;
lang = SFLocale::GetInstance();
Parameter: -
Returns: lang Pointer to the instance of the class "SFLocale"
Comment: During the whole lifetime of a running application always the same instance of the class is used. The class "SFLocale" create one (and only one) instance of the class (Singleton desing pattern).

Language()

Returns the native name of the current used language.
Usage: const char *land;
land = Language();
Parameter: -
Returns: land Pointer to the native name of the current language (e.g. "Deutsch", "English")
Comment: -

SetAppID(const char *app_id)

Set application ID for the program
Usage: const char *app_id = "siegfried backup locale";
SetAppID(app_id);
Parameter: app_id String pointer to an ID
Returns: -
Comment: Every application has it's own unique identifier for the "locale" files. All "locale" files include the ID. By this an application can easy check if the file can be used or not. The ID is set at the application start up (before the first call of "SetLanguage()"). The ID used during the function call of "SetLanguage()"). If the application ID loaded from the "locale" file is incorrect the file is rejected.

SetDefaultText(const char *mText[], int32 n, const char *name)

Set default text and language name.
Usage: const char *mText[SF_LAST_ID] = { ...};
inst32 n = SF_LAST_ID;
const char *name = "English";
SetDefaultText(mText, n, name);
Parameter: mText Default text field (table)
n amount of text (table) lines
name Native language name default text
Returns: -
Comment: -

SetLanguage(BDirectory *folder, const char *language)

Set language. Load data from "locale" file.
Usage: BDirectory *folder = new BDirectory(...);
const char *language = "Deutsch";
long ret;
ret = SetLanguage(folder, language);
Parameter: folder Pointer to folder where the "locale" files are.
language Native name of the language to load and set.
Returns: ret 0 = Ok, data load and set
1 = Error, can't read file
2 = Error, no "locale" file
3 = Error, wrong "locale" file (incorrect application ID)
4 = Error, file didn't include language name
5 = Error, invalid folder
Comment: -

SetLanguage(BEntry *folder, const char *language)

Set language. Load data from "locale" file.
Usage: BEntry *folder = new BEntry(...);
const char *language = "Deutsch";
long ret;
ret = SetLanguage(folder, language);
Parameter: folder Pointer to folder where the "locale" files are.
language Native name of the language to load and set.
Returns: ret 0 = Ok, data load and set
1 = Error, can't read file
2 = Error, no "locale" file
3 = Error, wrong "locale" file (incorrect application ID)
4 = Error, file didn't include language name
5 = Error, invalid folder
Comment: -

SetLanguage(BPath *folder, const char *language)

Set language. Load data from "locale" file.
Usage: BPath *folder = new BPath(...);
const char *language = "Deutsch";
long ret;
ret = SetLanguage(folder, language);
Parameter: folder Pointer to folder where the "locale" files are.
language Native name of the language to load and set.
Returns: ret 0 = Ok, data load and set
1 = Error, can't read file
2 = Error, no "locale" file
3 = Error, wrong "locale" file (incorrect application ID)
4 = Error, file didn't include language name
5 = Error, invalid folder
Comment: -

SetLanguage(const char *folder, const char *language)

Set language. Load data from "locale" file.
Usage: const char *folder = "...";
const char *language = "Deutsch";
long ret;
ret = SetLanguage(folder, language);
Parameter: folder Pointer to folder where the "locale" files are.
language Native name of the language to load and set.
Returns: ret 0 = Ok, data load and set
1 = Error, can't read file
2 = Error, no "locale" file
3 = Error, wrong "locale" file (incorrect application ID)
4 = Error, file didn't include language name
5 = Error, invalid folder
Comment: -

SetLanguage(entry_ref *folder, const char *language)

Set language. Load data from "locale" file.
Usage: entry_ref *folder = ...;
const char *language = "Deutsch";
long ret;
ret = SetLanguage(folder, language);
Parameter: folder Pointer to folder where the "locale" files are.
language Native name of the language to load and set.
Returns: ret 0 = Ok, data load and set
1 = Error, can't read file
2 = Error, no "locale" file
3 = Error, wrong "locale" file (incorrect application ID)
4 = Error, file didn't include language name
5 = Error, invalid folder
Comment: -

Text(int32 id)

Returns a localized text string to a given text id.
Usage: const char *text;
int32 id = SF_OK;
text = Text(id);
Parameter: id Identification number of a text (0 <= id < SF_LAST_ID)
Returns: text Pointer to a localized text.
NULL, if id is out of range.
Comment: Doesn't exist the localized text for an given id, the fuction returns a pointer to the default built-in text. If the id number is out of range NULL is returned.