xcstrings icon indicating copy to clipboard operation
xcstrings copied to clipboard

Pluralized values causing error

Open PaulEhrhardt opened this issue 11 months ago • 0 comments

Having pluralized values in your *.xcstrings file causes the script to raise errors. Changing the values to zero makes the script work without issues.

Error cause in xcstrings:

[...],
"weather_forecast_weather_alerts_%lld_expand_button" : {
      "localizations" : {
        "en" : {
          "variations" : {
            "plural" : {
              "one" : {
                "stringUnit" : {
                  "state" : "needs_review",
                  "value" : "weather_forecast_weather_alerts_%lld_expand_button"
                }
              },
              "other" : {
                "stringUnit" : {
                  "state" : "new",
                  "value" : "weather_forecast_weather_alerts_%lld_expand_button"
                }
              }
            }
          }
        }
      }
    }, 
[...]

Script Error output:

File "/Users/XYZ/xcstrings-main/xcstrings_Gemini.py", line 249, in main
    source_string = localizations["en"]["stringUnit"]["value"]
                    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'stringUnit'

PaulEhrhardt avatar Mar 12 '25 10:03 PaulEhrhardt