Git Product home page Git Product logo

smart-localization-2's Introduction

Smart Localization 2 by Niklas Borglund & Jakob Hillerström

Localizing your game has never been this easy. Localize your game with only a few mouse clicks.

Just open the Smart Localization Window in Window->Smart Localization and start by pressing "Create new localization system". Edit the root language file by adding some keys and base values.

To add a new language to your project, choose a language in the "Add/Update Languages" panel and click "Create". To edit and translate a language, press the "Translate" button on the language you want to work with in the Created Languages panel.

There's an example scene in SmartLocalization->Examples called LoadAllLanguages, which draws all the available languages and values on the screen. The code for the example is also included and lies within the same folder.

Building the Smart Localization Unity Package

You can build the unitypackage with the built in tools in unity manually - or you can use the gulp jobs in the project. The gulp jobs will by default run all the unit tests and export the package into a folder called "dist"

First, make sure you have npm installed - https://nodejs.org/en/download/

Then, either with terminal or the windows command prompt, locate yourself to the location of your clone of this repository and run the following commands:

First, you need to install the node modules required.

npm install

Then you only have to write the following command everytime you want to export the package given that your Unity installation is at the default location.

npm run gulp

If it's not in the default location, you can set it yourself with the --unityPath parameter in the gulp job.

npm --unityPath=<YOUR_PATH> run gulp'

Code Examples

//Returns a text value in the current language for the key
string myKey = LanguageManager.Instance.GetTextValue("MYKEY");
//Gets the audio clip for the current language
AudioClip myClip = LanguageManager.Instance.GetAudioClip("MYKEY"); 
//Gets the prefab game object for the current language
GameObject myPrefab = LanguageManager.Instance.GetPrefab("MYKEY");
//Gets the texture for the current language
Texture myTexture = LanguageManager.Instance.GetTexture("MYKEY");
//(Pro feature)Gets a localized TextAsset
TextAsset myTextAsset = LanguageManager.Instance.GetTextAsset("MYKEY");
//To cache the LanguageManager in a variable
LanguageManager languageManager = LanguageManager.Instance;
//Get a list of all the available languages
List<SmartCultureInfo> availableLanguages = thisLanguageManager.GetSupportedLanguages();
Get the smart culture info of the system language if it is supported. otherwise it will return null
SmartCultureInfo systemLanguage = thisLanguageManager.GetSupportedSystemLanguage();
//Check if a language is supported with an ISO-639 language code (string = "en" "sv" "es" etc.)
LanguageManager.Instance.IsLanguageSupported("en");
//Check if a language is supported with an instance of SmartCultureInfo
SmartCultureInfo swedishCulture = new SmartCultureInfo("sv", "Swedish", "Svenska", false);
LanguageManager.Instance.IsLanguageSupported(swedishCulture);
//Change a language with an ISO-639 language code ("en" "sv" "es" etc., Make sure the language is supported)
LanguageManager.Instance.ChangeLanguage("en");
//Change the language with a SmartCultureInfo instance
SmartCultureInfo swedishCulture = new SmartCultureInfo("sv", "Swedish", "Svenska", false);
LanguageManager.Instance.ChangeLanguage(swedishCulture);
//How to register on the event that fires when a language changed
LanguageManager.Instance.OnChangeLanguage += OnLanguageChanged; //OnLanguageChanged = delegate method that you created
//Enable extensive debug logging
LanguageManager.Instance.VerboseLogging = true;
//Check if a localized key exists
LanguageManager.Instance.HasKey("myKey")

smart-localization-2's People

Contributors

joaobsneto avatar niklasborglund avatar skymanrm 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.