Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trace formatting or parsing errors

Discussion in 'Localization Tools' started by RastaGrzywa, Mar 8, 2022.

  1. RastaGrzywa

    RastaGrzywa

    Joined:
    Jun 16, 2018
    Posts:
    12
    Hey guys,
    In docs there's section under this link: https://docs.unity3d.com/Packages/com.unity.localization@1.2/manual/LocalizationSettings.html that says we can trace any formatting or parsing errors, by subscribing to the corresponding events:
    Smart.Default.OnFormattingFailure
    Smart.Default.Parser.OnParsingFailure

    And my question is where should I subscribe to that event. Created a bit of code:
    Code (CSharp):
    1. private void Start()
    2. {
    3.     Smart.Default.OnFormattingFailure += OnFormatFailure;
    4.     Smart.Default.Parser.OnParsingFailure += OnParsingFailure;
    5. }
    6.  
    7. private void OnParsingFailure(object sender, ParsingErrorEventArgs e)
    8. {
    9.     Debug.LogError("Parsing failure");
    10. }
    11.  
    12. private void OnFormatFailure(object sender, FormattingErrorEventArgs e)
    13. {
    14.     Debug.LogError("Formatting failure");
    15. }
    And that doesn't work. Doesn't show any error logs. I wonder how that should looks like and how it works then?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,225
    Hey. You want to do LocalizationSettings.StringDatabase.SmartFormatter.OnFormattingFailure

    We don't use Smart.Default.
    I'll get the docs fixed
     
  3. RastaGrzywa

    RastaGrzywa

    Joined:
    Jun 16, 2018
    Posts:
    12
    Thanks for update in docs :)
    Unfortunately after change I see no improvements. Still nothing shows in log.

    Code (CSharp):
    1. class LocalizationFeedbackController : MonoBehaviour
    2. {
    3.     private void Start()
    4.     {
    5.         LocalizationSettings.StringDatabase.SmartFormatter.OnFormattingFailure += OnFormatFailure;
    6.     }
    7.  
    8.     private void OnFormatFailure(object sender, FormattingErrorEventArgs e)
    9.     {
    10.         Debug.LogError("Formatting failure");
    11.     }
    12. }
    upload_2022-3-8_18-34-2.png

    It displays 'OutputErrorInResult' setup from smart settings but no my subscribed function.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,225
    Could you please file a bug report? We will need to look into it.
     
  5. RastaGrzywa

    RastaGrzywa

    Joined:
    Jun 16, 2018
    Posts:
    12
    Sure, bug is reported.
     
    karl_jones likes this.