Skip to content

Commit

Permalink
(examples/with-next-translate) Removed Redundancies in Strings (verce…
Browse files Browse the repository at this point in the history
…l#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>
  • Loading branch information
brookton and ijjk authored Jan 5, 2022
1 parent 551c9d6 commit 2efc944
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
5 changes: 1 addition & 4 deletions examples/with-next-translate/locales/ar/home.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"arabic": "العربية",
"catalan": "الكاتالونية",
"change-arabic": "تغيير اللغة إلى العربية ",
"change-catalan": "تغيير اللغة إلى الكتالانية",
"change-english": "تغيير اللغة إلى اللغة الإنجليزية ",
"change-hebrew": "تغيير اللغة إلى العبرية",
"change-to": "تغيير اللغة إلى",
"description": "ابدأ بالتعديل",
"english": "الإنجليزية",
"hebrew": "العبرية",
Expand Down
5 changes: 1 addition & 4 deletions examples/with-next-translate/locales/ca/home.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 1 addition & 4 deletions examples/with-next-translate/locales/en/home.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 1 addition & 4 deletions examples/with-next-translate/locales/he/home.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"arabic": "עֲרָבִית",
"catalan": "קטלאנית",
"change-arabic": "שנה שפה לערבית",
"change-catalan": "שנה שפה לקטלונית",
"change-english": "שנה שפה לאנגלית",
"change-hebrew": "שנה את השפה לעברית",
"change-to": "שנה את השפה ל",
"description": "התחל על ידי עריכה",
"english": "אנגלית",
"hebrew": "עִברִית",
Expand Down
16 changes: 12 additions & 4 deletions examples/with-next-translate/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,36 @@ export default function Home() {
<Link href="/" locale="en">
<div className="card">
<h3>{t('home:english')}</h3>
<p>{t('home:change-english')}</p>
<p>
{t('home:change-to')} {t('home:english')}
</p>
</div>
</Link>

<Link href="/" locale="ca">
<div className="card">
<h3>{t('home:catalan')}</h3>
<p>{t('home:change-catalan')}</p>
<p>
{t('home:change-to')} {t('home:catalan')}
</p>
</div>
</Link>

<Link href="/" locale="ar">
<div className="card">
<h3>{t('home:arabic')}</h3>
<p>{t('home:change-arabic')}</p>
<p>
{t('home:change-to')} {t('home:arabic')}
</p>
</div>
</Link>

<Link href="/" locale="he">
<div className="card">
<h3>{t('home:hebrew')}</h3>
<p>{t('home:change-hebrew')}</p>
<p>
{t('home:change-to')} {t('home:hebrew')}
</p>
</div>
</Link>

Expand Down

0 comments on commit 2efc944

Please sign in to comment.