Skip to content

A platform for community discussion. Free, open, simple.

DEV: Lint MessageFormat strings to prevent usage of "one {foo 1 bar}" (#11608)

Gerhard Schlagerfc9155f3eee0
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 915f4f7eae1..b493b57567c 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2306,14 +2306,14 @@ en:
UNREAD, plural,
=0 {}
one {
- is <a href='{basePath}/unread'>1 unread</a>
+ is <a href='{basePath}/unread'># unread</a>
} other {
are <a href='{basePath}/unread'># unread</a>
}
} {
NEW, plural,
=0 {}
- one { {BOTH, select, true{and } false {is } other{}} <a href='{basePath}/new'>1 new</a> topic}
+ one { {BOTH, select, true{and } false {is } other{}} <a href='{basePath}/new'># new</a> topic}
other { {BOTH, select, true{and } false {are } other{}} <a href='{basePath}/new'># new</a> topics}
} remaining, or {CATEGORY, select, true {browse other topics in {catLink}} false {{latestLink}} other {}}"
@@ -3101,7 +3101,7 @@ en:
delete_spammer: "Delete Spammer"
# keys ending with _MF use message format, see https://meta.discourse.org/t/message-format-support-for-localization/7035 for details
- delete_confirm_MF: "You are about to delete {POSTS, plural, one {<b>1</b> post} other {<b>#</b> posts}} and {TOPICS, plural, one {<b>1</b> topic} other {<b>#</b> topics}} from this user, remove their account, block signups from their IP address <b>{ip_address}</b>, and add their email address <b>{email}</b> to a permanent block list. Are you sure this user is really a spammer?"
+ delete_confirm_MF: "You are about to delete {POSTS, plural, one {<b>#</b> post} other {<b>#</b> posts}} and {TOPICS, plural, one {<b>#</b> topic} other {<b>#</b> topics}} from this user, remove their account, block signups from their IP address <b>{ip_address}</b>, and add their email address <b>{email}</b> to a permanent block list. Are you sure this user is really a spammer?"
yes_delete_spammer: "Yes, Delete Spammer"
ip_address_missing: "(N/A)"
hidden_email_address: "(hidden)"
diff --git a/script/i18n_lint.rb b/script/i18n_lint.rb
index 7dd750b4c91..b00de751916 100644
--- a/script/i18n_lint.rb
+++ b/script/i18n_lint.rb
@@ -97,7 +97,7 @@ class LocaleFileValidator
@errors[:invalid_interpolation_key_format] << key
end
- if key.end_with?("_MF") && value.match?(/one {1.*?}/)
+ if key.end_with?("_MF") && value.match?(/one {.*?1.*?}/)
@errors[:invalid_message_format_one_key] << key
end
end