Skip to content

Commit

Permalink
Clean repeated static string interpolation (#5261)
Browse files Browse the repository at this point in the history
* changes for 'openverse' string literal

* removed interpolation for openverse

* changes to test files

* removing repeat string interpolation for about page

* Update the last 3 occurrences

* Update the Playwright utility

---------

Co-authored-by: Olga Bulat <[email protected]>
  • Loading branch information
tejaswarathe and obulat authored Jan 16, 2025
1 parent be13113 commit 56be647
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 214 deletions.
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
Expand Up @@ -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)}}`
}

Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/VHomepageContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ const {
tag="p"
class="mt-4 text-sr"
>
<template #openverse>Openverse</template>
<template #license>
<VLink
href="https://creativecommons.org/licenses/"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/VSafetyWall/VSafetyWall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
34 changes: 13 additions & 21 deletions frontend/src/pages/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/feedback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/pages/privacy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const handleChange = ({ checked }: { checked?: boolean }) => {
$t("privacy.intro.link")
}}</VLink>
</template>
<template #openverse>Openverse</template>
</i18n-t>

<h2>
Expand All @@ -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:[email protected]"
>[email protected]</VLink
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/pages/sensitive-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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/"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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">{{
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/sources.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading

0 comments on commit 56be647

Please sign in to comment.