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 Plural formatter doesn't accept ObjectReference variables?

Discussion in 'Localization Tools' started by geordiemhall, Oct 11, 2021.

  1. geordiemhall

    geordiemhall

    Joined:
    Jun 6, 2020
    Posts:
    20
    Hi there,

    I can submit a proper bug report about this if it's needed for tracking, but thought I'd post here first in case it it's actually a configuration issue on my side. We're on v1.0.1 of the package.

    We have a string table entry with english contents like "
    {ComboValue:plural:hit|hits}
    " with "smart string" ticked, and then have a MonoBehaviour that exposes a `ComboValue` integer property. We then have a LocalizeStringEvent using that string reference, with an ObjectReference local variable for ComboValue pointing to that component.

    In both the smart preview and at runtime, the string fails to be formatted. Tried using ordinal "0", as well as named "ComboValue" selector, but neither worked. Also tried making the exposed value a field instead of a property but same issue.

    Changing from an Object local variable to an Int local variable formatted just fine though, which makes me think it's a bug with the plural/object reference and not with the format pattern?

    PluralFormatter.png


    Cheers,
    Geordie
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Looks like you need to do 0.ComboValue

    The first picks the instance and the second picks the property inside the instance.
     
  3. geordiemhall

    geordiemhall

    Joined:
    Jun 6, 2020
    Posts:
    20
    Hm I gave that a try but it still seems to complain?

    upload_2021-10-13_14-20-9.png

    Is that expected for that syntax to need to change between formatter types? Because the "cond" formatter did seem to accept it without the `0.` prefix, it just left the questionmark at the start of the case. Although maybe I'm just misunderstanding the nuances + implicit behaviour of the selector process, and how that relates between the (indexed) arguments array passed programatically vs the named local/global variables you set up in the inspector.

    Eg. I would have expected since there aren't any arguments passed programatically, that the "0" ordinal wouldn't even be available, and that you'd have to use named arguments that correspond to a variable name defined in the local or global variables list?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Ah yes you are right, 0 wont work. We did at one point set the first local variable as item 0 but that didn't get into the release. So I think you want
    ComboValue.ComboValue:plural:

    Assuming the property is also called ComboValue.
    The first ComboValue to select the local variable and the 2nd to select the property inside the instance.