Search Unity

Get Localized String in Edit Mode

Discussion in 'Localization Tools' started by Calvares, Jul 19, 2021.

  1. Calvares

    Calvares

    Joined:
    Jul 11, 2018
    Posts:
    17
    So I've made custom Track Assets for a Timeline that support Localized Strings. The problem is that when I'm playing a timeline in edit mode the text that I'm getting with GetLocalizedString() functions is blank.
    I tried to Debug.Log a text given from GetLocalizedString() (in Edit mode again) and it says Null.
    Is there a workaround here? Because I want to display localized text when I'm building a timeline sequence.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    We do have editor support so it should work. It could be that you have no editor locale set to preview.
    Try setting one in Window/Asset Management/Localization Scene Controls.
     
  3. Calvares

    Calvares

    Joined:
    Jul 11, 2018
    Posts:
    17
    Sweet, it works, thanks! Didn't know about this thing.
     
    karl_jones likes this.
  4. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    40
    I'm facing the same problem.
    Of course I have set the Active Locale in Localization Scene Controls.
    Both LocalizedString.TableReference and LocalizedString.TableEntryReference.KeyId return the correct values.
    LocalizedString.GetLocalizedString() on the editor will return Null.
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    When do you call it? Is it during an assembly reload or whilst entering play mode? It may not work at those points. Otherwise it's worth filling a bug report so we can look into it.
     
  6. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    40
    I simply called GetLocalizedString() from the context menu.
    I tried it in a new project just to be sure, but it returned Null.
    I'll submit a bug report.
    Thank you.
     
    karl_jones likes this.
  7. shelim

    shelim

    Joined:
    Aug 26, 2017
    Posts:
    29
    I have run into the same problem. It is definitely a bug - but after some testing I found a workaround until it is fixed.

    Set Project Settings -> Localization -> Initialize Synchronously (at the bottom of page) to UNCHECKED. It will work correctly in edit mode now.

    upload_2022-2-13_23-34-5.png
     
    karl_jones likes this.
  8. shelim

    shelim

    Joined:
    Aug 26, 2017
    Posts:
    29
    Okay, some more testing... even with this set it is still sometimes falling to obtaining language entry. It looks like second, or even third call is successful, earlier ones still returns null
     
  9. shelim

    shelim

    Joined:
    Aug 26, 2017
    Posts:
    29
    Some more debugging. It fails here:

    As the `InternalOp.Version` is set to 7, and `m_Version` to 6, the `IsValid` call is returning false hence the entire call to `GetLocalizedString` returns default(TObject) which happen to be null for string

    upload_2022-2-14_0-0-19.png

    More info - this is for the Localization version 1.0.5 which happen to be newest available in Unity Editor. I have tried to install 1.1.1 by editing manifests, the problem is the same
     
    Last edited: Feb 13, 2022
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Thanks. In editor async operations should be completing immediately. Are you entering play mode at any point? It's possible that an operation is getting corrupt when switching between play mode and back.