Search Issue Tracker

By Design

Votes

1

Found in [Package]

1.0.0-pre.10

Issue ID

LOC-339

Regression

No

GetLocalizedString does not return fallback locale string when key value is empty

Package: Localization Package

-

Reproduction steps:
1. Open the user's attached project
2. Open the 'Scenes/Sample Scene' Scene
3. Enter Play mode
4. Select 'English (en-GB)' in the dropdown menu on the left
5. Click the 'Next Page' button on the right side

Expected result: fallback string is retrieved and visible
Actual result: no text is visible, GetLocalizedString returns null

Reproducible with: 1.0.0-pre.9, 1.0.0-pre.10 (2019.4.29f1, 2020.3.16f1, 2021.1.17f1, 2021.2.0b7, 2022.1.0a5)
Could not test with: 1.0.0-pre.8 and below (AsyncOperationHandle errors)

Note: fallback string returns null for other locales as well

  1. Resolution Note:

    Hi,

    After further investigation this behavior is actually by design.
    I can see in your script *UnityLocalizationManager* you are using a list of LocalizedStringTable. A StringTable does not support fallbacks, it will always return the entry, even if it is empty. This is intentional as you may want to access metadata etc and StringTables are not aware of fallbacks. If you want to get the entry of a table with fallback support you should use one of the following:

    - LocalizedString.
    - LocalizationSettings.StringDatabase.GetTableEntry
    - LocalizationSettings.StringDatabase.GetLocalizedString

    The fallback behavior is handled during the GetTableEntry stage. I updated your code and got it working with the following changes:

    {code:c#}
    void LoadStrings(StringTable stringTable)
    {
    switch (currentTopic)
    {
    case 0:
    baseText.text = LocalizationSettings.StringDatabase.GetLocalizedString(stringTable.TableCollectionName, huckDialogueStarter + currentPage, arguments:testValues);
    return;
    case 1:
    baseText.text = LocalizationSettings.StringDatabase.GetLocalizedString(stringTable.TableCollectionName, cutsceneStarter + currentPage, arguments:testValues);
    return;
    case 2:
    baseText.text = LocalizationSettings.StringDatabase.GetLocalizedString(stringTable.TableCollectionName, itemData[currentPage], arguments:testValues);
    return;
    }
    }
    {code}

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.