# Using Globalization in Applications

#### <a class="anchor" id="bkmrk--2"></a>Requirements for Multi Language Support

<div class="contents" id="bkmrk-cmake-setting-cander"><div class="contents"><div class="textblock">- CMake setting CANDERA\_GLOBALIZATION\_ENABLED is enabled
- Sources of CanderaGlobalization available

</div></div></div>#### <a class="anchor" id="bkmrk--3"></a>Example: Set Culture in the Player

The Player provides, if Globalization is enabled in <span style="color: rgb(230, 126, 35);">[Candera](http://dev.doc.cgistudio.at/APILINK/namespace_candera.html "[DataBinding_RefTypeSample]")</span>, a checkbox to select all cultures, which are available as language packs in the loaded asset.

<div class="contents" id="bkmrk-open-the-asset-conta"><div class="contents"><div class="contents"><div class="textblock">1. Open the asset containing language packs (MultiLanguagePack\_Asset\_Host.bin) and load the scene in the Player.
2. Select the desired language in the drop down list next to the globe icon in the top left corner

</div></div></div></div><div drawio-diagram="2207"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-4-1677042956.png" alt=""/></div>

<div class="contents" id="bkmrk--0"><div class="contents"><div class="textblock">  
</div></div></div>#### <a class="anchor" id="bkmrk--5"></a>Candera Globalization API

The following table explains the usage of Globalization interfaces and how they are used in application code.

<div class="contents" id="bkmrk-candera%3A%3Aglobalizati"><div class="textblock"><table class="doxtable" style="width: 100%;"><tbody><tr valign="top"><td style="width: 20.6487%;"><span style="color: rgb(230, 126, 35);">[Candera::Globalization::Culture](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture.html)</span></td><td style="width: 79.3513%;">Represents a language, region, and text direction - Locale: ASCII encoded character array, e.g. de\_AT. Use <span style="color: rgb(230, 126, 35);">[Candera::Globalization::Culture::GetLocale()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture.html#aea515e01a7afafe67db6282f7e6dfac4)</span>
- Display name: Platform-encoded character array (usually UTF-8), e.g. "German (Austria)". Use <span style="color: rgb(230, 126, 35);">[Candera::Globalization::Culture::GetDisplayName()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture.html#a5381ce8790ea6daca1d6e4e9face34dd)</span>
- Text direction: Enum describing text direction for culture. Use <span style="color: rgb(230, 126, 35);">[Candera::Globalization::Culture::GetTextDirection()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture.html#aa7e32e5200cfec29a063ae55e815d370)</span>

</td></tr><tr valign="top"><td style="width: 20.6487%;"><span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureManager](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_manager.html)</span></td><td style="width: 79.3513%;">Access to cultures and changing of current culture  
Singleton: <span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureManager::GetInstance()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_manager.html#a304b9b82d1ce5e85ce36de1683c87643)</span>

Retrieve available cultures:

```
    return CultureManager::GetInstance().GetCultureCount();
```

Get current culture:

```
    Culture::SharedPointer culture = CultureManager::GetInstance().GetCurrentCulture();
```

Get culture name:

```
    Culture::SharedPointer culture = CultureManager::GetInstance().GetCulture(index);
    return culture->GetDisplayName();
```

Set new culture:

```
    Culture::SharedPointer culture = CultureManager::GetInstance().GetCulture(index);
    FEATSTD_LOG_INFO(" -> Select culture '%s'", culture->GetDisplayName());
    rc = CultureManager::GetInstance().SetCurrentCulture(culture->GetLocale());
```

- <span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureManager::GetCulture(const Char\* locale) const ](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_manager.html#a11b6e5c19d1d119df057c640cbb6db3a)</span>- Retrieval of specific culture by locale

</td></tr><tr valign="top"><td style="width: 20.6487%;"><span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureChangeListener](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_change_listener.html)</span></td><td style="width: 79.3513%;">Base class for listeners to culture change events

Notification of CultureChangeEvents

- Listener has to derive from <span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureChangeListener](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_change_listener.html)</span>
    - override <span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureChangeListener::OnCultureChanged(const Culture&amp; culture)](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_change_listener.html#ad34d13c0afad927f5448437087da15f5)</span> {...} for handler
- Registration as listener 
    - <span style="color: rgb(230, 126, 35);">[Candera::Globalization::CultureManager::AddCultureChangeListener(CultureChangeListener\* listener)](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_globalization_1_1_culture_manager.html#ac59956a9a17161a614521bd3e83ec23b)</span>
- Deregistration of listener 
    - Candera::Globalization::CultureManager::RemoveCultureChangeListener(CultureChangeListener\* listener)

</td></tr><tr valign="top"><td style="width: 20.6487%;"><span style="color: rgb(230, 126, 35);">[FeatStd::String](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_string.html)</span> and <span style="color: rgb(230, 126, 35);">[FeatStd::TextId](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_text_id.html)</span></td><td style="width: 79.3513%;">Point of access to a text in currently active language

Non-translatable String

- Will not change with language
- Use constructor <span style="color: rgb(230, 126, 35);">[FeatStd::String::String(const TChar\*)](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_string.html#a2b5ab81b2f9de953b42677a508146831)</span>;

Translatable String

- Changes with language
- Text-Id from string value 
    - Use <span style="color: rgb(230, 126, 35);">[FeatStd::TextId::TextId(const Char\* id)](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_text_id.html#a433e7beda4e766070d0d356044f4a3f2)</span> to get the computed hash id from a given character id
    - Use <span style="color: rgb(230, 126, 35);">[FeatStd::String::String(const TextId&amp; id)](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_string.html#a5533f601ec5f8a72649d61fa9bde65ea)</span> to access the text for a given Text-Id ```
        <a class="code" href="http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_string.html">FeatStd::String</a> text(<a class="code" href="http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_text_id.html">FeatStd::TextId</a>("textField_1_3"));
        ```
- Direct Text-Id: "#\\&lt;HEX\_HASH\_VALUE\\&gt;" 
    - Use FeatStd::String::String(UInt32 id) to access the text for a given &lt;HEX\_HASH\_VALUE&gt; ```
        <a class="code" href="http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_string.html">FeatStd::String</a> text(0x13); // for accessing text referenced by a hex-value-id of 13
        ```

</td></tr></tbody></table>

</div></div>