mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
DEV: Use consistent interpolation key format in translations
From now on client strings can easily be reused on the server and you don’t have to think about choosing the right format anymore.
This commit is contained in:
parent
b3c8d36412
commit
0cf297725f
@ -20,7 +20,7 @@ export default Component.extend({
|
||||
)
|
||||
formattedName(name, nameKey, isCustomFlag, username) {
|
||||
if (isCustomFlag) {
|
||||
return name.replace("{{username}}", username);
|
||||
return name.replace(/{{username}}|%{username}/, username);
|
||||
} else {
|
||||
return I18n.t("flagging.formatted_name." + nameKey);
|
||||
}
|
||||
|
@ -10,7 +10,10 @@ export default Component.extend({
|
||||
@discourseComputed("rs.score_type.title", "reviewable.target_created_by")
|
||||
title(title, targetCreatedBy) {
|
||||
if (title && targetCreatedBy) {
|
||||
return title.replace("{{username}}", targetCreatedBy.username);
|
||||
return title.replace(
|
||||
/{{username}}|%{username}/,
|
||||
targetCreatedBy.username
|
||||
);
|
||||
}
|
||||
|
||||
return title;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -899,7 +899,7 @@ en:
|
||||
short_description: 'A violation of <a href="%{base_path}/guidelines">our community guidelines</a>'
|
||||
long_form: "flagged this as inappropriate"
|
||||
notify_user:
|
||||
title: "Send @{{username}} a message"
|
||||
title: "Send @%{username} a message"
|
||||
description: "I want to talk to this person directly and personally about their post."
|
||||
short_description: "I want to talk to this person directly and personally about their post."
|
||||
long_form: "messaged user"
|
||||
|
@ -141,13 +141,20 @@ describe "i18n integrity checks" do
|
||||
context "valid translations" do
|
||||
invalid_relative_links = {}
|
||||
invalid_relative_image_sources = {}
|
||||
invalid_interpolation_key_format = {}
|
||||
|
||||
each_translation(english_yaml) do |key, value|
|
||||
if value.match?(/href\s*=\s*["']\/[^\/]|\]\(\/[^\/]/i)
|
||||
invalid_relative_links[key] = value
|
||||
elsif value.match?(/src\s*=\s*["']\/[^\/]/i)
|
||||
end
|
||||
|
||||
if value.match?(/src\s*=\s*["']\/[^\/]/i)
|
||||
invalid_relative_image_sources[key] = value
|
||||
end
|
||||
|
||||
if value.match?(/\{\{.+?}}/)
|
||||
invalid_interpolation_key_format[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
it "uses %{base_url} or %{base_path} for relative links" do
|
||||
@ -159,6 +166,11 @@ describe "i18n integrity checks" do
|
||||
keys = invalid_relative_image_sources.keys.join("\n")
|
||||
expect(invalid_relative_image_sources).to be_empty, "The following keys have relative image sources, but do not start with %{base_url} or %{base_path}:\n\n#{keys}"
|
||||
end
|
||||
|
||||
it "uses the %{key} as interpolation key format" do
|
||||
keys = invalid_interpolation_key_format.keys.join("\n")
|
||||
expect(invalid_interpolation_key_format).to be_empty, "The following keys use {{key}} instead of %{key} for interpolation keys:\n\n#{keys}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -490,7 +490,7 @@ export default {
|
||||
},
|
||||
{
|
||||
name_key: "notify_user",
|
||||
name: "Notify {{username}}",
|
||||
name: "Notify %{username}",
|
||||
description:
|
||||
"This post contains something I want to talk to this person directly and privately about. Does not cast a flag.",
|
||||
short_description:
|
||||
|
@ -320,7 +320,7 @@ PreloadStore.store("site", {
|
||||
},
|
||||
{
|
||||
name_key: "notify_user",
|
||||
name: "Notify {{username}}",
|
||||
name: "Notify %{username}",
|
||||
description:
|
||||
"This post contains something I want to talk to this person directly and privately about.",
|
||||
long_form: "notified user",
|
||||
|
Loading…
Reference in New Issue
Block a user