Global variables don't work

Hi, I’m trying to use global variables to update values across multiple Localize String Events. However, none of them are able to correctly parse and display the global variables (they error out when trying to parse the nested global variable group). Funny thing is that the preview window in the components displays the correct string just fine.

This is what my Localization Settings looks like:

This is my Global group asset:
9125464--1266442--upload_2023-7-5_11-9-37.png

This is the error:
FormattingException: Error parsing format string: Could not evaluate the selector “g-vars” at 23
sium
-----------------------^
UnityEngine.Localization.SmartFormat.SmartFormatter.FormatError (UnityEngine.Localization.SmartFormat.Core.Parsing.FormatItem errorItem, System.Exception innerException, System.Int32 startIndex, UnityEngine.Localization.SmartFormat.Core.Formatting.FormattingInfo formattingInfo) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Smart Format/SmartFormatter.cs:347)
UnityEngine.Localization.SmartFormat.SmartFormatter.Format (UnityEngine.Localization.SmartFormat.Core.Formatting.FormattingInfo formattingInfo) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Smart Format/SmartFormatter.cs:319)
UnityEngine.Localization.SmartFormat.SmartFormatter.Format (UnityEngine.Localization.SmartFormat.Core.Formatting.FormatDetails formatDetails, UnityEngine.Localization.SmartFormat.Core.Parsing.Format format, System.Object current) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Smart Format/SmartFormatter.cs:286)
UnityEngine.Localization.SmartFormat.SmartFormatter.FormatWithCache (UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache& cache, System.String format, System.IFormatProvider formatProvider, System.Collections.Generic.IList1[T] args) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Smart Format/SmartFormatter.cs:257) UnityEngine.Localization.Tables.StringTableEntry.GetLocalizedString (System.IFormatProvider formatProvider, System.Collections.Generic.IList1[T] args, UnityEngine.Localization.Pseudo.PseudoLocale pseudoLocale) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Tables/StringTable.cs:176)
UnityEngine.Localization.Settings.LocalizedStringDatabase.GenerateLocalizedString (UnityEngine.Localization.Tables.StringTable table, UnityEngine.Localization.Tables.StringTableEntry entry, UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, UnityEngine.Localization.Locale locale, System.Collections.Generic.IList`1[T] arguments) (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedStringDatabase.cs:251)
UnityEngine.Localization.LocalizedString.RefreshString () (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Localized Reference/LocalizedString.cs:231)
UnityEngine.Localization.Components.LocalizeStringEvent.RefreshString () (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Component Localizers/LocalizeStringEvent.cs:77)
UnityEngine.Localization.Components.LocalizeStringEvent.OnValidate () (at ./Library/PackageCache/com.unity.localization@1.3.2/Runtime/Component Localizers/LocalizeStringEvent.cs:138)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

The preview window doesn’t have any problems:
9125464--1266445--upload_2023-7-5_11-10-57.png

Everything looks correct in the screenshot. Could you try updating to the latest package version 1.4.4? If its not in the package manager you can edit the manifest.json file in the packages folder.
If that doesnt work, could you share an example project so I can take a look?

Updating from 1.4.2 to 1.4.4 did the trick, thanks!

Update: after a restart, the problem is here again. It seems to be a bug of the Localization Package.

Could you please file a bug report so we can investigate?

Done

As a workaround, I just assigned the global variable asset as a local variable to each Localize String Event that use it. Still annoying though.

It should work as you expected. Can you share the project with the issue?

I submitted a bug report which is now awaiting review. I don’t think I can share the whole project here since it’s quite big in size.

Do you know the bug number?

Sure, it’s CASE IN-46612

After further investigation, I found the cause of the problem: there were two Localization Settings Assets in the project. The one I was editing through the Project Settings apparently was not the same one that the Localize String Events were pointing to. Still, it’s weird that various parts of the library (preview windows and components) choose different settings assets.

I was just about to say you had 2 settings. We did used to have a warning in the inspector about this, ill have to investigate why it’s not displayed anymore.