I have no clue how the localization works with the remote content system. I just simply set them to preload and set the addressables settings like this
Do I simply load it with that built in label? Like maybe LoadAssetsAsync(“Locale-id-ID”)? Will it works this way?
I wonder why unity doesn’t write a basic tutorial to load localization remotely from addressables? Or am I missing something in this doc?
From localization there is no difference if the asset is remote or local, the code is exactly the same. The difference is in how you set up the addressable groups.
No difference from the localization code. You call the code in the same way regardless. Thats the point in Addressables, you handle the assets in the same way. You call LoadAsset and Addressables handles locating and loading the asset, all you need to do is wait for the async operation to complete.
The group resolver is just for deciding what group an asset goes into (if you dont want to use the defaults) when its created via the localization system, it doesnt change how you load assets. You should not need to load anything by label named, thats just for the localization internals. You load them like you would any other asset, if its a string table you use the Table collection name.
I have one question tho. If I want to make it remote content can I use similar settings like my other remote addressables settings?
Also I want to tell you my understanding about this and please correct me if I’m wrong.
Check if there’s any localization caches with Addressables.GetDownloadSizeAsync(label);
If it’s empty then download with Addressables.DownloadDependenciesAsync(label);
Load resource locations with Addressables.LoadResourceLocationsAsync(label);
Load assets with Addressables.LoadAssetAsync<StringTableCollection>(location);
As for the label, I just have to insert it with TableCollectionName right?
My content is dynamic. Means we maybe update it in the future.
What I’m doing is I populate all the keys in the scriptable objects. Then I set the table collection name and the entry of the LocalizedStringEvent using the keys in that scriptable objects.
In this page you set everything manually in the editor. While in my system I mostly instantiate the items and set them like this
public override void SetupSlide(BaseSlideVariantSO so)
{
_sectionTitleLSE.SetTable(so.tableCollectionName);
_sectionTitleLSE.SetEntry(so.slideTitle);
if (so is SlideVariant4SO a)
{
_slideSO = a;
foreach (var page in _slideSO.contentPages)
{
_mixedSlides.Add(page);
}
if (a.slideInjections.Count > 0)
{
SetupSlideInjection(a.slideInjections);
}
}
}
So this item is not needed? The point is I have no clue working with the localization remote content.
This is my full script of loading the localization
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization.Settings;
namespace PLN.Core
{
public class LocalizationManager : MonoBehaviour
{
public const string LOCALE = "PLN_LOCALE";
public int LastLocaleIndex
{
get
{
var temp = 0;
if (PlayerPrefs.HasKey(LOCALE))
{
temp = PlayerPrefs.GetInt(LOCALE);
}
return temp;
}
}
[SerializeField] private List<Sprite> _localSprites;
internal void PreloadLocalizations()
{
IEnumerator InitializeLocales()
{
yield return LocalizationSettings.InitializationOperation;
if (PlayerPrefs.HasKey(LOCALE))
{
PlayerPrefs.GetInt(LOCALE);
}
else
{
PlayerPrefs.SetInt(LOCALE, 0);
}
ChangeLocale(PlayerPrefs.GetInt(LOCALE));
}
StartCoroutine(InitializeLocales());
}
public List<TMPro.TMP_Dropdown.OptionData> GetLocaleDropdownOptions()
{
var options = new List<TMPro.TMP_Dropdown.OptionData>();
for (int i = 0; i < LocalizationSettings.AvailableLocales.Locales.Count; i++)
{
options.Add(new TMPro.TMP_Dropdown.OptionData("", _localSprites[i]));
}
Debug.LogWarning("Call loc: " + options.Count);
return options;
}
public void ChangeLocale(int index)
{
Debug.LogWarning("Change loc: " + index);
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
PlayerPrefs.SetInt(LOCALE, index);
}
}
}
To ensure compliance with Apple’s guidelines (similar guidelines are followed by other vendors), it is necessary to request user consent prior to downloading any data. This was the reason why we failed the submission, Apple told us:
However, it’s not a Localization System issue specifically.
Those items looks like the asset bundles, yes they are needed. You put them locally or remote on a server. The Addressables catalog needs to know where they are and this is setup during the build. If you want to know more I suggest asking in the addressables forum as my knowledge is limited. https://forum.unity.com/forums/addressables.156/
As for your script, you don’t need to store the selected locale with a player pref, we already have support for this. Add the PlayerPrefsLocaleSelector to the selectors in the localization settings.
We have an example locale selector in the package samples.
I would have thought Addressables would have something in place to do this. I can ask the team.