Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean repeated static string interpolation #5261

122 changes: 61 additions & 61 deletions frontend/i18n/data/en.json5

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions frontend/i18n/scripts/translations.mjs
Original file line number Diff line number Diff line change
@@ -160,9 +160,17 @@ const replacePlaceholders = (json, locale, deprecatedKeys, invalidKeys) => {
* translations are replaced with camelCased keys the app expects.
*/
function replacer(_, match) {
const targetWords = { openverse: "Openverse" }

if (match.includes("-")) {
recordProblems(match, deprecatedKeys)
}

// Check if the match is one of the target words
if (match in targetWords) {
return `{'${targetWords[match]}'}`
}

return `{${kebabToCamel(match)}}`
}

1 change: 0 additions & 1 deletion frontend/src/components/VHomepageContent.vue
Original file line number Diff line number Diff line change
@@ -139,7 +139,6 @@ const {
tag="p"
class="mt-4 text-sr"
>
<template #openverse>Openverse</template>
<template #license>
<VLink
href="https://creativecommons.org/licenses/"
1 change: 0 additions & 1 deletion frontend/src/components/VSafetyWall/VSafetyWall.vue
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ const handleShow = () => {
class="mt-2"
keypath="sensitiveContent.singleResult.learnMore"
>
<template #openverse>Openverse</template>
<template #link>
<VLink class="text-link hover:underline" href="/sensitive-content">{{
$t("sensitiveContent.singleResult.link")
34 changes: 13 additions & 21 deletions frontend/src/pages/about.vue
Original file line number Diff line number Diff line change
@@ -15,22 +15,21 @@ definePageMeta({
const { t } = useI18n({ useScope: "global" })

useHead({
title: `${t("about.title", { openverse: "Openverse" })} | Openverse`,
title: `${t("about.title")} | Openverse`,
})
</script>

<template>
<VContentPage>
<h1>
{{ $t("about.title", { openverse: "Openverse" }) }}
{{ $t("about.title") }}
</h1>
<p>
{{ $t("about.description.content", { openverse: "Openverse" }) }}
{{ $t("about.description.content") }}
</p>

<p>
<i18n-t scope="global" keypath="about.collection.content.a" tag="span">
<template #openverse>Openverse</template>
<template #commonCrawl>
<VLink href="https://commoncrawl.org/">Common Crawl</VLink>
</template>
@@ -39,14 +38,12 @@ useHead({
</p>

<p>
{{ $t("about.planning.content.a", { openverse: "Openverse" }) }}
{{ $t("about.planning.content.a") }}
{{ $t("about.planning.content.b") }}
<i18n-t scope="global" keypath="about.planning.content.c" tag="span">
<template #openverse>Openverse</template>
<template #repository>
<VLink href="https://github.com/wordpress/openverse">{{
$t("about.planning.repository", {
openverse: "Openverse",
github: "GitHub",
})
}}</VLink>
@@ -65,7 +62,7 @@ useHead({
</p>

<p>
{{ $t("about.transfer.content.a", { openverse: "Openverse" }) }}
{{ $t("about.transfer.content.a") }}
<i18n-t scope="global" keypath="about.transfer.content.b" tag="span">
<template #creativeCommons>
<VLink
@@ -83,11 +80,11 @@ useHead({
</p>

<p>
{{ $t("about.declaration.content.a", { openverse: "Openverse" }) }}
{{ $t("about.declaration.content.a") }}
<i18n-t scope="global" keypath="about.declaration.content.b" tag="span">
<template #terms>
<VLink href="https://creativecommons.org/terms/">{{
$t("about.declaration.terms", { openverse: "Openverse" })
$t("about.declaration.terms")
}}</VLink>
</template>
</i18n-t>
@@ -98,29 +95,24 @@ useHead({
</h2>

<i18n-t scope="global" keypath="externalSourcesPage.intro" tag="p">
<template #openverse>Openverse</template>
<template #link>
<VLink href="/sources">{{ $t("externalSourcesPage.link") }}</VLink>
</template>
</i18n-t>

<p>
{{ $t("externalSourcesPage.license.a", { openverse: "Openverse" }) }}
{{ $t("externalSourcesPage.license.b", { openverse: "Openverse" }) }}
{{ $t("externalSourcesPage.license.a") }}
{{ $t("externalSourcesPage.license.b") }}
{{ $t("externalSourcesPage.license.c") }}
</p>

<p>
{{ $t("externalSourcesPage.explanation", { openverse: "Openverse" }) }}
{{ $t("externalSourcesPage.explanation") }}
</p>

<p>
{{
$t("externalSourcesPage.relationships.a", { openverse: "Openverse" })
}}
{{
$t("externalSourcesPage.relationships.b", { openverse: "Openverse" })
}}
{{ $t("externalSourcesPage.relationships.a") }}
{{ $t("externalSourcesPage.relationships.b") }}
</p>

<h2>
@@ -153,7 +145,7 @@ useHead({
</i18n-t>

<p>
{{ $t("externalSourcesPage.why.new.a", { openverse: "Openverse" }) }}
{{ $t("externalSourcesPage.why.new.a") }}
{{ $t("externalSourcesPage.why.new.b") }}
{{ $t("externalSourcesPage.why.new.c") }}
</p>
1 change: 0 additions & 1 deletion frontend/src/pages/feedback.vue
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ useHead({ title: `${t("feedback.title")} | Openverse` })
</h1>
<i18n-t scope="global" keypath="feedback.intro" tag="p">
<!-- eslint-disable @intlify/vue-i18n/no-raw-text -->
<template #openverse>Openverse</template>
<template #slack>
<VLink href="https://wordpress.slack.com/messages/openverse/"
>#openverse</VLink
2 changes: 0 additions & 2 deletions frontend/src/pages/privacy.vue
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ const handleChange = ({ checked }: { checked?: boolean }) => {
$t("privacy.intro.link")
}}</VLink>
</template>
<template #openverse>Openverse</template>
</i18n-t>

<h2>
@@ -60,7 +59,6 @@ const handleChange = ({ checked }: { checked?: boolean }) => {
</h2>

<i18n-t scope="global" keypath="privacy.contact.content" tag="p">
<template #openverse>Openverse</template>
<template #email>
<VLink href="mailto:openverse@wordpress.org"
>openverse@wordpress.org</VLink
4 changes: 0 additions & 4 deletions frontend/src/pages/sensitive-content.vue
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ useHead({ title: `${t("sensitive.title")} | Openverse` })
keypath="sensitive.description.content.c"
tag="span"
>
<template #openverse>Openverse</template>
<template #wpCoc
><VLink
href="https://make.wordpress.org/handbook/community-code-of-conduct/"
@@ -119,7 +118,6 @@ useHead({ title: `${t("sensitive.title")} | Openverse` })
keypath="sensitive.designations.userReported.description.b"
tag="span"
>
<template #openverse>Openverse</template>
<template #gutenbergMediaInserter>
<VLink
href="https://learn.wordpress.org/tutorial/add-media-and-openverse-images-to-your-content-directly-from-the-inserter/"
@@ -154,7 +152,6 @@ useHead({ title: `${t("sensitive.title")} | Openverse` })
keypath="sensitive.designations.sensitiveText.description.b"
tag="span"
>
<template #openverse>Openverse</template>
<template #sensitiveTermsList>
<VLink
href="https://github.com/wordpress/openverse-sensitive-terms"
@@ -194,7 +191,6 @@ useHead({ title: `${t("sensitive.title")} | Openverse` })
keypath="sensitive.designations.sensitiveText.metadata.a"
tag="span"
>
<template #openverse>Openverse</template>
<template #openverseOrg>Openverse.org</template>
<template #notAvailable>
<VLink href="https://github.com/WordPress/openverse/issues/2594">{{
1 change: 0 additions & 1 deletion frontend/src/pages/sources.vue
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@ useHead({ title: `${t("sources.title")} | Openverse` })
</p>

<i18n-t scope="global" keypath="sources.ccContent.europeana" tag="p">
<template #openverse>Openverse</template>
<template #link>
<VLink href="https://www.europeana.eu/en">Europeana</VLink>
</template>
Loading
Loading