Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug No Locale could be selected error

Discussion in 'Localization Tools' started by PixelCells, Oct 6, 2023.

  1. PixelCells

    PixelCells

    Joined:
    Jul 29, 2018
    Posts:
    7
    When starting the game - getting this error.
    Tried solution from this comment, but didn't helped.

    Code (CSharp):
    1. No Locale could be selected:
    2. The following (22) Locales were considered:
    3.     English (en)
    4.     Russian (ru)
    5.     Czech (cs)
    6.     Belarusian (be)
    7.     Chinese (Simplified) (zh-CN)
    8.     Dutch (nl)
    9.     Finnish (fi)
    10.     French (fr)
    11.     German (de)
    12.     Indonesian (id)
    13.     Italian (it)
    14.     Japanese (ja)
    15.     Korean (ko)
    16.     Polish (pl)
    17.     Portuguese (Brazil) (pt-BR)
    18.     Portuguese (Portugal) (pt-PT)
    19.     Portuguese (pt)
    20.     Spanish (Spain) (es-ES)
    21.     Spanish (es)
    22.     Turkish (tr)
    23.     Ukrainian (uk)
    24.     Vietnamese (vi)
    25. The following (0) IStartupLocaleSelectors were used:
    26.  
    27. UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable () (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Component Localizers/LocalizeStringEvent.cs:101)
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    The clue is in the error message at the end

    The following (0) IStartupLocaleSelectors were used:

    You dont have any startup selectors so it doesnt know what language to pick. Did you delete them all?
    There should be at least 1 in the Localization Settings.
    https://docs.unity3d.com/Packages/c...ual/LocalizationSettings.html#locale-selector
     
  3. PixelCells

    PixelCells

    Joined:
    Jul 29, 2018
    Posts:
    7
    Thank you very much! You can't beliebe how much you saved us!

    Extra question:
    I've seen your other answer and need little help. In this comment you explain how to insert float into local variable. But how do we insert localized string into localize string event from code?
     
    karl_jones likes this.
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
  5. PixelCells

    PixelCells

    Joined:
    Jul 29, 2018
    Posts:
    7
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    https://docs.unity3d.com/Packages/c...ocalization.LocalizedString.html#constructors

    Code (csharp):
    1. public LocalizedString withNestedTranslation = new LocalizedString("My String Table", "My Game Text")
    2. {
    3.    { "some-text", new StringVariable { Value = "Hello World" } },
    4.    { "nested", new LocalizedString("My String Table", "My Nested Text")
    5.      {
    6.          { "score", new IntVariable { Value = 100 } },
    7.      }}
    8. };
    https://docs.unity3d.com/Packages/c...ization_LocalizedString_Remove_System_String_

    Code (csharp):
    1. const string variableName = "my-variable";
    2. localizedString.Add(variableName, new LocalizedString());
     
  7. PixelCells

    PixelCells

    Joined:
    Jul 29, 2018
    Posts:
    7
    For what reason can an error be caused when setting a value to the localizer?
    When calling the localizer again - everything works

    Code (CSharp):
    1.  
    2. FormattingException: Error parsing format string: Could not evaluate the selector "antName" at 26
    3. Upgrade <color=#EE9F43ff>{antName}</color> to level <color=#EE9F43ff>{level}</color>?
    4. --------------------------^
    5. 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.4.3/Runtime/Smart Format/SmartFormatter.cs:347)
    6. UnityEngine.Localization.SmartFormat.SmartFormatter.Format (UnityEngine.Localization.SmartFormat.Core.Formatting.FormattingInfo formattingInfo) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Smart Format/SmartFormatter.cs:319)
    7. 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.4.3/Runtime/Smart Format/SmartFormatter.cs:286)
    8. UnityEngine.Localization.SmartFormat.SmartFormatter.FormatWithCache (UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache& cache, System.String format, System.IFormatProvider formatProvider, System.Collections.Generic.IList`1[T] args) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Smart Format/SmartFormatter.cs:257)
    9. UnityEngine.Localization.Tables.StringTableEntry.GetLocalizedString (System.IFormatProvider formatProvider, System.Collections.Generic.IList`1[T] args, UnityEngine.Localization.Pseudo.PseudoLocale pseudoLocale) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Tables/StringTable.cs:177)
    10. 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.4.3/Runtime/Settings/Database/LocalizedStringDatabase.cs:299)
    11. UnityEngine.Localization.LocalizedString.RefreshString () (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Localized Reference/LocalizedString.cs:230)
    12. UnityEngine.Localization.LocalizedString.AutomaticLoadingCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] loadOperation) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Localized Reference/LocalizedString.cs:773)
    13. UnityEngine.Localization.LocalizedString.HandleLocaleChange (UnityEngine.Localization.Locale _) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Localized Reference/LocalizedString.cs:762)
    14. UnityEngine.Localization.LocalizedString.ForceUpdate () (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Localized Reference/LocalizedString.cs:642)
    15. UnityEngine.Localization.LocalizedString.add_StringChanged (UnityEngine.Localization.LocalizedString+ChangeHandler value) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Localized Reference/LocalizedString.cs:129)
    16. UnityEngine.Localization.Components.LocalizeStringEvent.RegisterChangeHandler () (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Component Localizers/LocalizeStringEvent.cs:154)
    17. UnityEngine.Localization.Components.LocalizeStringEvent.set_StringReference (UnityEngine.Localization.LocalizedString value) (at Library/PackageCache/com.unity.localization@1.4.3/Runtime/Component Localizers/LocalizeStringEvent.cs:59)
    18. Improvement.RenderInfo (Card antCard) (at Assets/scripts/Improvement/Improvement.cs:567)
    19. Improvement.ClickCard (Card antCard) (at Assets/scripts/Improvement/Improvement.cs:223)
    20. WorkshopCart.Click () (at Assets/scripts/UI/WorkshopCart.cs:12)
    21. UnityEngine.Events.InvokableCall.Invoke () (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
    22. UnityEngine.Events.UnityEvent.Invoke () (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
    23. UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
    24. UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
    25. UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
    26. UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
    27. UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    You have an error in your smart string

    Error parsing format string: Could not evaluate the selector "antName" at 26
    Upgrade <color=#EE9F43ff>{antName}</color> to level <color=#EE9F43ff>{level}</color>?

    Your string needs a variable called antName

    Code (csharp):
    1. public LocalizedString withNestedTranslation = new LocalizedString("My String Table", "My Game Text")
    2. {
    3.    { "some-text", new StringVariable { Value = "Hello World" } },
    4.    // maybe antName here?
    5.    { "nested", new LocalizedString("My String Table", "My Nested Text")
    6.      {
    7.          { "score", new IntVariable { Value = 100 } },
    8.          // Maybe antName here if nested?
    9.      }}
    10. };
     
  9. PixelCells

    PixelCells

    Joined:
    Jul 29, 2018
    Posts:
    7
    Thanks! It helped!