Skip to content

i18n: lint against more invalid usages of gettext helpers

Paul Gascou-Vaillancourt requested to merge lint-against-namespace-gettext into main

f3f35799

This extends the require-valid-i18n-helpers rule to detect usages of gettext (__) with a namespace. In such cases, the namespace is displayed as is in the UI, so we should either remove the namespace, or use the s__ helper instead.

note: Technically, this could flag some usages as being invalid when a | character is included on purpose within the string. IMO, it's better to "overlint" and ignore the false positives, rather than not lint against this at all and let some ignored namespaces appear in the UI.

What motivated this change is that I stumbled across one of those usages while browsing GitLab.com:

Screenshot_2023-03-22_at_10.19.05_AM

https://gitlab.com/gitlab-org/gitlab/-/blob/a0ec39682c17455c3e3431e9aea265535fcc595e/app/assets/javascripts/merge_request_tabs.js#L319

63fcbb54

This ensures that, when pluralizing some translation with n_gettext, both the singular and plural forms use the same translation namespace, or no namespace at all.

Edited by Paul Gascou-Vaillancourt

Merge request reports