Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 6 and Version 7 of code/doc/Language


Ignore:
Timestamp:
Sep 29, 2008, 4:03:14 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Language

    v6 v7  
    44== Description ==
    55
    6 The [wiki:Language] is a [wiki:singleton] that handles strings in different languages. It replaces hardcoded strings by labeled strings, where the coder only uses the label and the [wiki:Language] searches for the localised string in the [wiki:ConfigValueContainer configured] language-file. Every string has a fallback-value that is used if there is no localised version or no language was configured. The language can be configured by changing the ''language_'' entry in the [wiki:ConfigValueContainer config-file].
     6Language is a [wiki:singleton] that handles strings in different languages. It replaces hardcoded strings by labeled strings, where the coder only uses the label and the Language searches for the localised string in the [wiki:ConfigValueContainer configured] language-file. Every string has a fallback-value that is used if there is no localised version or no language was configured. The language can be configured by changing the ''language_'' entry in the [wiki:ConfigValueContainer config-file].
    77
    88A new language-entry can be added with the !AddLanguageEntry(label, fallbackstring) macro and the localisation can be retrieved with !GetLocalisation(label).
    99
    10 All labels and the corresponding fallback strings are written to ''translation_default.lang''. If the fallback-string gets changed in the code, ''translation_default.lang'' changes too. If a new label gets added in the code, it gets added to ''translation_default.lang''. You can't change labels or fallback-strings in this file, it will be set back to the default. You can use ''translation_default.lang'' as a sample for a new language file. See [wiki:Language#Addinganewlanguage] for more information about this.
     10All labels and the corresponding fallback strings are written to ''translation_default.lang''. If the fallback-string gets changed in the code, ''translation_default.lang'' changes too. If a new label gets added in the code, it gets added to ''translation_default.lang''. You can't change labels or fallback-strings in this file, it will be set back to the default. You can use ''translation_default.lang'' as a sample for a new language file. See [wiki:Language#Addinganewlanguage the chapter at the end] for more information about this.
    1111
    1212== Macros ==
    1313
    14  * '''!AddLanguageEntry('''''label''''', '''''fallbackstring''''')''': Adds a new entry to the [wiki:Language] by defining a unique label and a fallback string that gets used in case there is no localisation.
     14 * '''!AddLanguageEntry('''''label''''', '''''fallbackstring''''')''': Adds a new entry to the Language by defining a unique label and a fallback string that gets used in case there is no localisation.
    1515 * '''!GetLocalisation('''''label''''')''': Returns the localisation of the given label.
    1616
    1717== Functions ==
    1818
    19  * '''getLanguage()''': Returns a reference to the only existing instance of the [wiki:Language] class.
    20  * '''addEntry('''''label''''', '''''fallback string''''')''': Adds a new entry to the [wiki:Language] by defining a unique label and a fallback string that gets used in case there is no localisation.
     19 * '''getLanguage()''': Returns a reference to the only existing instance of the Language class.
     20 * '''addEntry('''''label''''', '''''fallbackstring''''')''': Adds a new entry to the Language by defining a unique label and a fallback string that gets used in case there is no localisation.
    2121 * '''getLocalisation('''''label''''')''': Returns the localisation of the given label.
    2222
     
    2828// Displays the users age
    2929int age = 20;
    30 Language::getLanguage().addEntry("user_age", "Age");
    31 std::cout << Language::getLanguage().getLocalisation("user_age") << ": " << age << std::endl;
     30AddLanguageEntry("user_age", "Age");
     31std::cout << GetLocalisation("user_age") << ": " << age << std::endl;
    3232}}}
    3333
     
    6767
    6868Now you can change the config-value ''language_'' to "''xxxxx''" in orxonox.ini. The translated entries should now be used in the game.
     69
     70'''Attention''': Language entries are only added to the file if they are at least once executed. Otherwise you wont find them in the file. If you need a complete translation, you have to search the code for all entries. If you know a better solution, just tell me. ;)