Giter Site home page Giter Site logo

localizedstring's Introduction

LocalizedString for Axmol Engine

Localize your strings to several languages in Axmol Engine.

Inspired by the "Multiple language support" tutorial by Den.

Preparations

Include the following files in your Source folder:

LocalizedString.h
LocalizedString.cpp

You can edit LocalizedString.cpp in order to add more languages or changing the names and formats of your localization files.

Available languages:

CHINESE JAPANESE FRENCH ITALIAN GERMAN SPANISH DUTCH RUSSIAN HUNGARIAN PORTUGUESE
KOREAN ARABIC NORWEGIAN POLISH TURKISH UKRAINIAN ROMANIAN BULGARIAN BELARUSIAN

Available file formats:

  • .json
  • .plist

Create the localization files inside your Content folder.

In this extension the files are called Localizable_xx.json by default. This is an example on how you can create one in any text editor:

Localizable_en.json

{
    "play_button_label":"Play",
    "mode_selection_label":"Select mode",
    "pause_label":"Pause"
}

The first element is the key you have to call to get the localized string, second is the localized string.

How to use

Add #include "LocalizedString.h" in your class file.

Use the following call with your key to get the translated string:

std::string textToLocalize = LocalizedString::getInstance()->getLocalizedString("key_to_translate");

Note: If the key is not found inside the files, the same key will be returned.


If you have a lot of text, you can make the call shorter by using something similar to this:

string HelloWorld::localizedString(string key)
{
    return LocalizedString::getInstance()->getLocalizedString(key);
}

Then you can just use string text = localizedString("key_to_translate");


Final note: adding more languages is out of the reach of this extension. In case of need, these are some of the files inside Axmol Engine you may want to check:

localizedstring's People

Contributors

danialias avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.