Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Problem with localization of dynamic text

Discussion in 'Localization Tools' started by DYV, Nov 2, 2023.

  1. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Sorry for my poor English and programming skills :)
    I have a script that puts some text to the upgrade panel:
    Code (CSharp):
    1.  public void Set(UpgradeData upgradeData)
    2.     {
    3.         upgradeNameText.text = upgradeData.Name;
    4. }
    It gets the text from here:
    Code (CSharp):
    1. public class UpgradeData : ScriptableObject
    2. {
    3.     public string Name;
    4. }
    It works fine but now I need to localize this text
    So I added to upgradeData this:
    Code (CSharp):
    1. public class UpgradeData : ScriptableObject
    2. {
    3.     public string Name;
    4.     public LocalizedString localeStringName;
    5. }
    and added to script this:
    Code (CSharp):
    1.   public void Set(UpgradeData upgradeData)
    2.     {
    3.         upgradeNameText.text = upgradeData.Name;
    4.         localizeNameStringEvent.StringReference = upgradeData.localeStringName;
    5.     }
    I added to my upgrade panel LocalizeStringEvent and I can see that it gets a key from upgradeData but the text is not changing (see attached picture). It should be replaced (at least I hope so) by a description but it does not work.
    Could you help me?
    What have I done to localize my upgrade panel?
    Thank you
     

    Attached Files:

  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,149
    Does the Update String event contain a reference to text in the LocalizedString?
    upload_2023-11-2_15-46-14.png

    If you click the Localize option from the TextMeshPro context menu it will add a configured LocalizedStringEvent component and configure it for you.
     
    DYV likes this.
  3. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Bingo! I completely forgot about it :)
    Thank you so much!
     
    karl_jones likes this.