From 2efc944cb9e2670c24deb089b1567f8002c417ae Mon Sep 17 00:00:00 2001 From: David Brookton <19512437+brookton@users.noreply.github.com> Date: Wed, 5 Jan 2022 11:25:00 -0700 Subject: [PATCH] (examples/with-next-translate) Removed Redundancies in Strings (#29501) ## `with-next-translate` Example Refactor - [x] Linting passes ## Purpose for changes - The existing locals folder is using a redundant string structure which continuously repeats "Change language to " in separate instances in separate languages alongside separate language translations. - This PR is a simple refactor to extract "change language to" to it's own string, and references already existing strings defining the language translation. ## Why they might be helpful - A user looking to implement this pattern should consider reducing redundancies as early as possible to scale an app, thus I believe it would be helpful for this example. Notes: - these original translations were done via google translate - verified that these strings still make sense and translate properly in every locale / language - these strings are meant to be examples, translations have not been verified with a translation agency. Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com> --- .../with-next-translate/locales/ar/home.json | 5 +---- .../with-next-translate/locales/ca/home.json | 5 +---- .../with-next-translate/locales/en/home.json | 5 +---- .../with-next-translate/locales/he/home.json | 5 +---- examples/with-next-translate/pages/index.js | 16 ++++++++++++---- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/examples/with-next-translate/locales/ar/home.json b/examples/with-next-translate/locales/ar/home.json index 4543b416dda30..bfed894f65e73 100644 --- a/examples/with-next-translate/locales/ar/home.json +++ b/examples/with-next-translate/locales/ar/home.json @@ -1,10 +1,7 @@ { "arabic": "العربية", "catalan": "الكاتالونية", - "change-arabic": "تغيير اللغة إلى العربية ", - "change-catalan": "تغيير اللغة إلى الكتالانية", - "change-english": "تغيير اللغة إلى اللغة الإنجليزية ", - "change-hebrew": "تغيير اللغة إلى العبرية", + "change-to": "تغيير اللغة إلى", "description": "ابدأ بالتعديل", "english": "الإنجليزية", "hebrew": "العبرية", diff --git a/examples/with-next-translate/locales/ca/home.json b/examples/with-next-translate/locales/ca/home.json index f7ec8cf75f401..fc59aa8606390 100644 --- a/examples/with-next-translate/locales/ca/home.json +++ b/examples/with-next-translate/locales/ca/home.json @@ -1,10 +1,7 @@ { "arabic": "Àrab", "catalan": "Català", - "change-arabic": "Canvia a la versió en àrab", - "change-catalan": "Canvia a la versió en català", - "change-english": "Canvia a la versió en anglès", - "change-hebrew": "Canvieu a la versió hebrea", + "change-to": "Canvieu a la versió en", "description": "Comença editant", "english": "Anglès", "hebrew": "Hebreu", diff --git a/examples/with-next-translate/locales/en/home.json b/examples/with-next-translate/locales/en/home.json index 264dd02f23d99..83813a7c7853a 100644 --- a/examples/with-next-translate/locales/en/home.json +++ b/examples/with-next-translate/locales/en/home.json @@ -1,10 +1,7 @@ { "arabic": "Arabic", "catalan": "Catalan", - "change-arabic": "Change language to Arabic", - "change-catalan": "Change language to Catalan", - "change-english": "Change language to English", - "change-hebrew": "Change language to Hebrew", + "change-to": "Change language to", "description": "Get started by editing", "english": "English", "hebrew": "Hebrew", diff --git a/examples/with-next-translate/locales/he/home.json b/examples/with-next-translate/locales/he/home.json index 3b5a275c66a26..03be1023c97da 100644 --- a/examples/with-next-translate/locales/he/home.json +++ b/examples/with-next-translate/locales/he/home.json @@ -1,10 +1,7 @@ { "arabic": "עֲרָבִית", "catalan": "קטלאנית", - "change-arabic": "שנה שפה לערבית", - "change-catalan": "שנה שפה לקטלונית", - "change-english": "שנה שפה לאנגלית", - "change-hebrew": "שנה את השפה לעברית", + "change-to": "שנה את השפה ל", "description": "התחל על ידי עריכה", "english": "אנגלית", "hebrew": "עִברִית", diff --git a/examples/with-next-translate/pages/index.js b/examples/with-next-translate/pages/index.js index ed065164e734d..515026bf8572b 100644 --- a/examples/with-next-translate/pages/index.js +++ b/examples/with-next-translate/pages/index.js @@ -27,28 +27,36 @@ export default function Home() {
{t('home:change-english')}
++ {t('home:change-to')} {t('home:english')} +
{t('home:change-catalan')}
++ {t('home:change-to')} {t('home:catalan')} +
{t('home:change-arabic')}
++ {t('home:change-to')} {t('home:arabic')} +
{t('home:change-hebrew')}
++ {t('home:change-to')} {t('home:hebrew')} +