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
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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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}