How to add change language option in game

Hello,
I want to add language change option in-game. But I am new in coding and localization. can someone please help me on code?
Thanks.

There is a sample in the package called LocaleMenuIMGUI that should give you something to start with.
Open the package manager and look at the samples section for the package.

1 Like

Thanks for quick help. As I never use script for implementing UIs. it’s really tough to understand UI part of those scripts.
I want UI to look like my game UI style (I added some text using Photoshop for better understanding):

6176616--676197--language.jpg

6180051--676833--list.gif Here is an example scene with 2 different ways to create a language selection menu.
These samples will also be in the next release
:slight_smile:

6180051–676902–ugui sample.unitypackage (11.3 KB)

2 Likes

Thank you so much for this great help :). But when I imported this package, console gives me 182 errors. Most are for words with “”. Like [test] [SetUp] etc.

Example:
The type or namespace name ‘SetUp’ could not be found (are you missing a using directive or an assembly reference?)

So, I deleted them (Are they needed?) But after deleting all these words there is still 16 errors of these:
The type or namespace name ‘Pool’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
The type or namespace name ‘NUnit’ could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name ‘IPrebuildSetup’ could not be found (are you missing a using directive or an assembly reference?)

Ah for some reason it exported way too much. You have a bunch of the Localization tests :smile:
ok here is a cut down version with just what you need

6180051–676902–ugui sample.unitypackage (11.3 KB)

1 Like

Ok, Thanks. Localization change is working fine in editor but in Android device it is Not clickable in dropdown mode (And maybe same with the other one). I tried previously with the sample package LocaleMenuIMGUI available in package manager and that time also same thing. Nothing was visible that time too. is IMGUI support in Android devices?

Other than that can we add Language option like this (Available in LocaleMenuIMGUI):
Russian (Russian in russian language)
Arabic (Arabic in arabic language)

If this is something easy to implement then please add this feature otherwise never mind.

It should work in Android. Are you using the new input system?

1 Like

No, I am not using new input system.

Just this is visible, and clicking on it not opening drop down.

while debugging my game, I found these errors, maybe helpfull:

08-08 16:38:54.923: E/Unity(21408): MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[[System.Collections.Generic.IList`1[[UnityEngine.Localization.Locale, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
08-08 16:38:54.923: E/Unity(21408):   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.923: E/Unity(21408):   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.923: E/Unity(21408):   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.923: E/Unity(21408):   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, System.Int32 operationHash, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.923: E/Unity(21408):   at UnityEngi
08-08 16:38:54.951: E/Unity(21408): MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[[System.Collections.Generic.IList`1[[UnityEngine.Localization.Locale, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
08-08 16:38:54.951: E/Unity(21408):   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.951: E/Unity(21408):   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.951: E/Unity(21408):   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.951: E/Unity(21408):   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, System.Int32 operationHash, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000000000000000000000>:0
08-08 16:38:54.951: E/Unity(21408):   at UnityEngi

Are you using stripping? It won’t work with code stripping at the moment due to a bug with SerialiseReference.
Have you built the addressable assets?

1 Like

I disabled strip engine code but no help. I am not using addressable assets. just addressables added by Localization Package. I don’t know much about addressable So, I never touched anything related this.

To use Localization in the player you need to build the Addressables. Windows/Asset Management/Addressable/Groups.
Click Build at the top and build player content. Now build the android game and it should work.

2 Likes

Sorry to disturb you again but which one is player content? there is New build, Clean Build, Update a Previous Build and many options inside those Builds.

Try doing a new build.

1 Like

Thank you so much, It finally worked now. But when I am restarting game language setting back to English. How to save selected language?

What does your Localization settings look like? Click the + button for the locale selectors. I think there’s one called player Prefs selector. Drag that to the top.

3 Likes

FYI: on 0.7.1.preview it doesn’t seem to be added by default, which I think would be a reasonable thing to consider doing.

1 Like

Sorry to bother, but I tried your: ugui sample.unitypackage to see what I was missing in creating a langue selection menu and though it works in unity with no errors on console my visual studio is very angry throwing errors saying that "UI namespace doesn’t exist in the namespace “UnityEngine”. I’m using unity 2020.3.30f1