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
- UnityLinker causes crash when outputting snapshot data for very large projects
- Camera Preview does not detect multiple cameras with same GameObject name
- Crash on TypeTreeIterator::Children() when renaming a corrupted asset while Asset Serialization is set to Mixed
- Cameras (Camera.targetDisplay) render only to Display 0 in the Player when Multi-Display setup is used and DX12 API is set
- [Vulkan] _CameraOpaqueTexture produces a feedback effect on Android Adreno devices when using Vulkan
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}