Skip to content

Add validation rule to prevent suspicious # usage outside of plural expressions #31

@faultyserver

Description

@faultyserver

With the NoUnnecessaryPlurals validation rule in place, translators sometimes manually fix messages in a way that leads to no more errors, but also a non-functional string. For example:

{intervalCount, plural, one {#ヶ月} other {#ヶ月}}

This string has an unnecessary plural and should have it removed. Attempting to manually fix this string is likely to end up with:

#ヶ月

But this is now incorrect and won't render as expected, since # is not valid outside of a plural arm. Instead, the correct solution here is to change the variable to a plain number:

{intervalCount, number}ヶ月

This is what the diagnostic's autofix will suggest and implement, but we can't currently prevent the incorrect value from being applied manually instead.

What we can do, though, is add a validation rule to detect any # outside of a plural arm and warn about its existence. It's fairly rare for # to be used in plain message text, but if issues do come up, the workaround would be to use escape sequences like \# to prevent it from being treated like a usual placeholder, and the rule can be configured as warning-only to prevent blockages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions