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

Follow-up to 6b53f26f
This commit is contained in:
Gerhard Schlager 2021-01-04 12:29:20 +01:00 committed by GitHub
parent ff54d3a024
commit fc9155f3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -2306,14 +2306,14 @@ en:
UNREAD, plural, UNREAD, plural,
=0 {} =0 {}
one { one {
is <a href='{basePath}/unread'>1 unread</a> is <a href='{basePath}/unread'># unread</a>
} other { } other {
are <a href='{basePath}/unread'># unread</a> are <a href='{basePath}/unread'># unread</a>
} }
} { } {
NEW, plural, NEW, plural,
=0 {} =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} 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 {}}" } remaining, or {CATEGORY, select, true {browse other topics in {catLink}} false {{latestLink}} other {}}"
@ -3101,7 +3101,7 @@ en:
delete_spammer: "Delete Spammer" 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 # 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" yes_delete_spammer: "Yes, Delete Spammer"
ip_address_missing: "(N/A)" ip_address_missing: "(N/A)"
hidden_email_address: "(hidden)" hidden_email_address: "(hidden)"

View File

@ -97,7 +97,7 @@ class LocaleFileValidator
@errors[:invalid_interpolation_key_format] << key @errors[:invalid_interpolation_key_format] << key
end 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 @errors[:invalid_message_format_one_key] << key
end end
end end