Localization for Mobile

Hello Karl,

It’s me again… :sweat_smile:

I’ve finished implementing localization, all my text is working on PC (about 70% fine, I’ll explain later), but now I’m trying to use it on mobile, as my game is for Android.

I haven’t found any extra step that was needed to make it work on mobile, so I just followed the tutorials, the problem is that the language won’t change, I’m getting this error:

10-30 18:50:39.853 14971 27703 E Unity   : 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]]
10-30 18:50:39.853 14971 27703 E Unity   :   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
10-30 18:50:39.853 14971 27703 E Unity   :   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
10-30 18:50:39.853 14971 27703 E Unity   :   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0
10-30 18:50:39.853 14971 27703 E Unity   :   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, UnityEngine.ResourceManagement.Util.IOperationCacheKey cacheKey, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000

Found it using the command prompt and using: Unity\Hub\Editor\2020.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools>adb logcat Unity: D *:S
Here’s a pic to better ilustrate what happens every time I click the button that was supposed to change the language.

And here’s the function the button calls:

public void SetLocale(Locale locale)
    {
        LocalizationSettings.SelectedLocale = locale;
        m_InitializeOperation = LocalizationSettings.SelectedLocaleAsync;
    }

Here’s my translation code, in case it helps:

    public string Translate (string source)
    {
        LocalizedString stringComponent = new LocalizedString();
        stringComponent.TableReference = "Revenot Localization";
        stringComponent.TableEntryReference = source;

        return stringComponent.GetLocalizedString();       
    }

And lastly, but not least, I said 70% of the times before, because on PC sometimes instead of translating the texts it shows a message “Loading…”, but it never loads, I have to stop the application and run it again to translate.

I know it’s a bit long this post, but I truly believe you can help me :wink:

The first issue can be fixed by updating to the latest version of 2020.3.
See if you still have the other problem after that.

I’m using 2020.3 already 7616092--946594--upload_2021-10-30_19-49-5.png

That’s an old version, you need the latest patch version. Update to the latest version of 2020.3 via the hub

Hello,

I’ve updated to version 7617997--947062--upload_2021-10-31_19-39-21.png but I’m still getting the same error:

10-31 19:38:40.624 27830 29579 E Unity   : 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]]
10-31 19:38:40.624 27830 29579 E Unity   :   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
10-31 19:38:40.624 27830 29579 E Unity   :   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
10-31 19:38:40.624 27830 29579 E Unity   :   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0
10-31 19:38:40.624 27830 29579 E Unity   :   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, UnityEngine.ResourceManagement.Util.IOperationCacheKey cacheKey, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000

Here’s a pic:

Did you rebuild the addressable assets after updating?

Sorry, but I have no clue what that means…

I searched for a solution on the forums and found this https://discussions.unity.com/t/748486/12 , tried the solution that says to add this link.xml

<linker>
    <assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
    <type fullname="UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" preserve="all" />
    <type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
    <type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
    <type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
    <type fullname="UnityEngine.ResourceManagement.AsyncOperations" preserve="all" />
    </assembly>
    <assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
    <type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
    </assembly>
</linker>

But it doesn’t work as well.

Can you indicate a tutorial for that?

https://docs.unity3d.com/Packages/com.unity.localization@1.0/manual/QuickStartGuideWithVariants.html#preview-and-configure-your-build

2 Likes

My bad, I completely missed that step.

Also about the loading, I figured out what I missed.

Problem solved.

Thank you again.

1 Like

Thank you! this is exactly what I was looking for. you save my life! I appreciate it.

1 Like