A platform for community discussion. Free, open, simple.
REFACTOR: Update Message Format string to simplify translation
Gerhard Schlagerd059c64485a8
diff --git a/app/assets/javascripts/discourse/app/components/suggested-topics.js b/app/assets/javascripts/discourse/app/components/suggested-topics.jsindex 66c7d9fd656..ad0c6671706 100644--- a/app/assets/javascripts/discourse/app/components/suggested-topics.js+++ b/app/assets/javascripts/discourse/app/components/suggested-topics.js@@ -80,11 +80,6 @@ export default Component.extend({},_topicBrowseMoreMessage(topic) {- const opts = {- latestLink: `<a href="${getURL("/latest")}">${I18n.t(- "topic.view_latest_topics"- )}</a>`,- };let category = topic.get("category");if (@@ -94,17 +89,6 @@ export default Component.extend({category = null;}- if (category) {- opts.catLink = categoryBadgeHTML(category);- } else {- opts.catLink =- '<a href="' +- getURL("/categories") +- '">' +- I18n.t("topic.browse_all_categories") +- "</a>";- }-let unreadTopics = 0;let newTopics = 0;@@ -114,21 +98,24 @@ export default Component.extend({}if (newTopics + unreadTopics > 0) {- const hasBoth = unreadTopics > 0 && newTopics > 0;-return I18n.messageFormat("topic.read_more_MF", {- BOTH: hasBoth,+ HAS_UNREAD_AND_NEW: unreadTopics > 0 && newTopics > 0,UNREAD: unreadTopics,NEW: newTopics,- CATEGORY: category ? true : false,- latestLink: opts.latestLink,- catLink: opts.catLink,+ HAS_CATEGORY: category ? true : false,+ categoryLink: category ? categoryBadgeHTML(category) : null,basePath: getURL(""),});} else if (category) {- return I18n.t("topic.read_more_in_category", opts);+ return I18n.t("topic.read_more_in_category", {+ categoryLink: categoryBadgeHTML(category),+ latestLink: getURL("/latest"),+ });} else {- return I18n.t("topic.read_more", opts);+ return I18n.t("topic.read_more", {+ categoryLink: getURL("/categories"),+ latestLink: getURL("/latest"),+ });}},diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex a093f98215f..0b74d42eb62 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -2863,25 +2863,47 @@ en:show_links: "show links within this topic"collapse_details: "collapse topic details"expand_details: "expand topic details"- read_more_in_category: "Want to read more? Browse other topics in %{catLink} or %{latestLink}."- read_more: "Want to read more? %{catLink} or %{latestLink}."+ read_more_in_category: "Want to read more? Browse other topics in %{categoryLink} or <a href='%{latestLink}'>view latest topics</a>."+ read_more: "Want to read more? <a href='%{categoryLink}'>Browse all categories</a> or <a href='%{latestLink}'>view latest topics</a>."unread_indicator: "No member has read the last post of this topic yet."# This string uses the ICU Message Format. See https://meta.discourse.org/t/7035 for translation guidelines.- read_more_MF: "There {- UNREAD, plural,- =0 {}- one {- is <a href='{basePath}/unread'># unread</a>- } other {- are <a href='{basePath}/unread'># unread</a>+ #+ # Both UNREAD and NEW are greater than 0 when HAS_UNREAD_AND_NEW is true+ # Either UNREAD or NEW is greater than 0 when HAS_UNREAD_AND_NEW is false+ read_more_MF: |+ { HAS_UNREAD_AND_NEW, select,+ true {+ { UNREAD, plural,+ =0 {}+ one { There is <a href="{basePath}/unread"># unread</a> }+ other { There are <a href="{basePath}/unread"># unread</a> }+ }+ { NEW, plural,+ =0 {}+ one { and <a href="{basePath}/new"># new</a> topic remaining, }+ other { and <a href="{basePath}/new"># new</a> topics remaining, }+ }+ }+ false {+ { UNREAD, plural,+ =0 {}+ one { There is <a href="{basePath}/unread"># unread</a> topic remaining, }+ other { There are <a href="{basePath}/unread"># unread</a> topics remaining, }+ }+ { NEW, plural,+ =0 {}+ one { There is <a href="{basePath}/new"># new</a> topic remaining, }+ other { There are <a href="{basePath}/new"># new</a> topics remaining, }+ }+ }+ other {}+ }+ { HAS_CATEGORY, select,+ true { or browse other topics in {categoryLink} }+ false { or <a href="{basePath}/latest">view latest topics</a> }+ other {}}- } {- NEW, plural,- =0 {}- 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 {}}"# This string uses the ICU Message Format. See https://meta.discourse.org/t/7035 for translation guidelines.bumped_at_title_MF: "{FIRST_POST}: {CREATED_AT}\n{LAST_POST}: {BUMPED_AT}"