Default configuration
This quick start uses OCL default configuration, which only supports strings. Check the Automatic Setup section for more information on configuration.
One Click Localization (OCL) is a Localization Tool for Unity designed to be easy and fast to use.
The aim of OCL is that... you don't think about localization... OCL is based on values instead of keys like most of the localization systems, that's why you don't need to take care of it until you really want localize your project.
Its customizable automatic setup and its generic component adapter will let you localize a project in minutes, whithout a single line of code.
To use the Test App in the Editor, you must first load its setup located in OneClickLocalization/Demo/Saved_Setup/DemoSetup.asset
You can then build and run it for any platform.
This quick start uses OCL default configuration, which only supports strings. Check the Automatic Setup section for more information on configuration.
All OCL content is located in a single directory "OneClickLocalization"
The Setup Window is used to configure OCL and start automatic setups.
OCL saves all its configuration data and localizations (used at runtime) in a single asset file OCLSetup.asset located in "Assets/OneClickLocalization/Resources" folder.
Be sure to add this file to your Source Control, to use Cloud Build and keep setup and localizations.
Saves the current configuration and localizations to the specified path.
You can't save outside of the project Assets folder
Load the specified setup asset and replaces the current one.
You will lose current configuration and localizations.
This options can be modified during runtime via the Script API
If unchecked, OCL is deactivated.
If checked, OCL automatically detects language by using Application.systemLanguage
Available if Use system's language is unchecked. Select the language used by OCL.
If checked, OCL API will return default language value when translation is null.
Usefull when you don't want check null values by yourself and avoid blank texts in your UI.
If checked, setup process will add OCLComponentAdapter to GameObjects found with a supported type.
If checked, setup process will extract data from the supported types to the localization list. You can then edit this localizations with the Localization Window
Specify lists of components to include or exclude from setup process.
By default, only components supported by OCLComponentAdapter are in the include list :
UnityEngine.UI.Text, UnityEngine.UI.Image, UnityEngine.UI.RawImage, UnityEngine.TextMesh, UnityEngine.AudioSource, UILabel (NGui)
If checked, setup process will parse objects from scenes
If checked, setup process will parse prefabs from the Assets folder.
If checked, setup process will parse ScriptableObjects from the Assets folder. It will extract strings from field (going recursively though lists, arrays and objects) and though root object properties (no recursivity here).
The language of your content before localization.
The table displays all the selected languages, the ratio of ids localized and the option to add/remove a language.
When you remove a language, you lose all the OCL data related to it, use carefully.
Opens the Localization Window
You must have an Azure portal account to use translator. There is a 12 months free evaluation when you create one with 2 millions character free/month
See this documentation to generate a key : Text Translator API Doc
Add your Resource key from Azure portal in the Key input (key is something like "adf86b4e3d1a488f84db076092e19f16", you can grab it from the "Manage keys" section in Azure portal)
Translator can be used though the Localization Window :
You can also use the "Translate all" button, it will translate all the entries visible in the table (based on the filters)
WARNING : be sure to use "global" configuration when you create a new Azure Translator cognitive service on the portal, or you could get "401 errors"
There is no Undo possible after a reset, you'll lose all OCL related data, be sure to have backups of your data (with export or source control of the OCLSetup asset) before you use it.
The reset will :
The Localization Window is an integrated editor for all your localizations : string, Sprite, Texture or AudioClip
A localization can have two states for a language :
When using OCL from script API, be sure to check if returned value is null.
For strings : null and empty are differenciated, if you want a string to be null : use the Reset button
Edit Localizations Window supports Undo / Redo and line returns.
Strings support parameters for dynamic content.
Use bracket numbered ids : ${#}
Example :
OCL will then automatically replace parameters using regular expressions.
You can import and export your strings to xml and csv formats
<?xml version="1.0" encoding="UTF-8"?>
<localization>
<strings>
<string stringId="String to localize 1">
<value lang="French">String à localiser 1</value>
<value lang="German">I can't speak German 1</value>
</string>
<string stringId="Another string to localize">
<value lang="French">Une autre String à localiser</value>
<value lang="German">I still can't speak German</value>
</string>
</strings>
</localization>
Uses coma separator, to avoid any problem during import, it is recommended to wrap all your strings in double quotes.
StringId,French,German
String to localize 1,String à localiser 1,I can't speak German 1
Another string to localize,Une autre String à localiser,I still can't speak German
"String to localize with, special ' characters","String avec caracteres speciaux,'",I can't speak German... really
Components are based on the OCL Script API, they apply the localization data to the GameObjects.
Only one component currently exist OCLComponentAdapter designed for ease of use and fast integration. More will come soon dedicated to performances
Automatically localize supported components on the same GameObject, no configuration needed.
Localization is currently supported for the following components (with corresponding type)
To add it to a GameObject :
You enable or disable types for the component. This is not dynamic during runtime for performance reasons.
OCL exposes full access to its configuration and data though a complete C# API
All the API is accessed from the static class OneClickLocalization.OCL
OCL only uses UnityEngine.SystemLanguage to determine language, no locale (en_En, fr_FR, etc...)
Delegate | Description |
---|---|
|
Called when Active state changes |
|
Called when selected language changes |
|
Called when a language is added or removed from the the languages list |
|
Called when a localization is modified |
Method | Description |
---|---|
|
Get OCL active state |
|
Set OCL active state |
|
Set the language used by OCL, has not effect if IsLanguageAuto is true |
|
Returns language used by OCL.
If IsLanguageAuto is true : returns Application.systemLanguage. If IsLanguageAuto is false : returns language defined with SetLanguage. Default value is SystemLanguage.English |
|
If true, OCL uses Application.systemLanguage for localization. If false, OCL uses GetCustomLanguage for localization |
|
Defines if OCL should use Application.systemLanguage or GetLanguage for localization |
|
Add a new language. Has no effect if language is already in GetLanguages |
|
Removes a language. Has no effect if language is not in GetLanguages. |
|
Returns supported languages. Use AddLanguage to add a new one and RemoveLanguage to remove one. If addDefaultLanguage is true, defaultLanguage will be in the list even if it has not been added |
|
Main method of the API Generic version of GetLocalization Returns the translation of the given object if its type is supported, its id is present and current language is supported, null otherwise |
|
Typed versions of GetLocalization |
|
Returns the translation of the given string for the given language. This method shouldn't be called directly as it won't handle active, defaultLanguage and forceLanguage parameters. Call it only if you need to access localization data directly without taking care of OCL setup. |
|
Typed versions of GetLocalization(Sprite, lang) |
|
Generic version of SetLocalization Set the translation for the given id and language. Has no effect if language is not in GetLanguages. Use AddLanguage to add a new language. |
|
Typed versions of SetLocalization |
string localization = OCL.GetLocalization("my text to localize");
string localization = OCL.GetLocalization("my text to localize", SystemLanguage.German);
// Languages list init
List<string> languagesStrings = new List<string>();
// Add supported languages
foreach (SystemLanguage supportedLanguage in OCL.GetLanguages())
{
languagesStrings.Add(supportedLanguage.ToString());
}
languageDropdown.AddOptions(languagesStrings);
string selectedLanguage = languageDropdown.options[languageDropdown.value].text;
OCL.SetLanguage((SystemLanguage) Enum.Parse(typeof(SystemLanguage), selectedLanguage));
SystemLanguage language = SystemLanguage.German;
if (OCL.GetLanguages(false).Contains(language))
{
Debug.Log("Selected language already there.");
}
else
{
OCL.AddLanguage(language);
}
if (OCL.GetLanguages().Contains(language))
{
OCL.SetLocalization("localized text", language, "My new value for this localized text");
Debug.Log("Localization updated");
}
else
{
Debug.Log("Selected language is not supported, use AddLanguage()");
}
For complete examples, see the Demo App code shipped with OCL
Found a bug? Any question? Contact us 7/7, day and night! (but don't expect immediate answer at night... or on sunday... and saturday... And maybe not too early in the morning... at least not before first coffee)