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

Add Korean localization for content pages and application strings #270

Merged
merged 14 commits into from
Mar 23, 2024

Conversation

sogoagain
Copy link
Contributor

Hello,

This pull request adds Korean localization for the following:

  • Translated content pages (.ko.md files)
  • Korean translations for application strings (common.json file)

If you have any feedback or suggestions, please let me know.

Thank you. :)

Copy link

vercel bot commented Mar 13, 2024

@sogoagain is attempting to deploy a commit to the Satoshi Nakamoto Institute Team on Vercel.

A member of the Team first needs to authorize it.

@bitstein
Copy link
Contributor

@sogoagain This is awesome! FYI, I had forgotten to do a few updates after adding Vietnamese content yesterday, so there is a merge conflict. A few updates, and a few deletions.

I ought to look into some of the cloud platforms that connect with i18next, so that translations of site strings can be managed better. I do worry that this basic setup will prove itself to be rather fragile.

@sogoagain
Copy link
Contributor Author

@bitstein Thanks for the heads up! I've rebased the branch and resolved the conflicts. All good now.
It would be nice to have a translation management tool. Let me know if there's anything else I can do to help!

@bitstein
Copy link
Contributor

I'm going to need to investigate what is wrong with my i18next setup. I'm not seeing translated strings display anymore. I'll also look into how to connect with a service like Crowdin.

@sogoagain
Copy link
Contributor Author

@bitstein I encountered a similar issue where the translated strings didn't show up when running pnpm dev. However, after running pnpm build followed by pnpm start, the translations displayed correctly. My guess is that when using pnpm dev, the common.json file might not be properly loaded at runtime.

Hopefully this helps narrow down the problem.

@bitstein
Copy link
Contributor

Thanks, I was able to recreate this. What I've found is on the dev server, PageLayout will have en as a prop before ko as a prop, and so I think it loads the English common.json rather than the Korean one. I'm not sure where that particular en value is coming from, though, because the actual page.tsx rendering the PageLayout has the correct value during the render.

@bitstein
Copy link
Contributor

When I turn off turbo builds on the dev server, it loads the Korean. This is probably why it works in the production server. PageLayout still renders 3 times, rather than just once, though, which I do not understand.

@sogoagain
Copy link
Contributor Author

@bitstein I investigated the issue and found that the reason for the triple rendering of PageLayout seems unrelated to the Korean text not being displayed. The development server is rendering both the not-found.tsx and app/[locale]/not-found.tsx pages, where the locale value is fixed to en. To clarify, the user-requested page should be rendered with ko, and only the 404 page should use en.

However, the real problem is that when using the turbo option, the values from common.json are not being read correctly. This can be verified by modifying the resourcesToBackend code in i18nTranslation.ts to log the resources:

.use(
  resourcesToBackend(
    (language: string, namespace: string, callback: ReadCallback) => {
      import(`../../locales/${language}/${namespace}.json`)
        .then(({ default: resources }) => {
          console.log(resources);
          callback(null, resources);
        })
    }
  ),
)

The console output shows that each key is assigned an empty string:

{
  About: '',
  Library: '',
  Mempool: '',
  Authors: '',
  Contact: '',
...

Interestingly, if we hardcode the language in resourcesToBackend, like this:

.use(
  resourcesToBackend(
    (language: string, namespace: string, callback: ReadCallback) => {
      import(`../../locales/ko/${namespace}.json`)
        .then(({ default: resources }) => {
          console.log(resources);
          callback(null, resources);
        })
    }
  ),

The common.json for that language is loaded correctly:

{
  About: '소개',
  Library: '라이브러리',
  Mempool: '멤풀',
  Authors: '작성자',
  Contact: '문의',
...

As you mentioned, disabling the turbo option resolves the issue and allows common.json to be loaded for each language. Based on my research, it seems that the development server's Turbopack does not support dynamic imports.

Related issue: vercel/next.js#56531

Thank you.

@bitstein
Copy link
Contributor

@sogoagain Thank you for thoroughly documenting this. I basically went through this exact step-by-step debugging today as well. According to the website they do handle dynamic imports, but that wasn't helping me. https://turbo.build/pack/docs/features/imports#dynamic-imports

I suspect this might be fixed as Turbopack gets out of beta, given that issue already has related PRs that have been merged. Perhaps we can merge this and just keep an eye on progress on this. The guys working on next-intl are also dealing with this same issue. amannn/next-intl#898

There are a few things I realized I forgot to add the translations for, so I will do that tomorrow and at your convenience, you could finish up the remaining strings.

I really appreciate all of this.

@sogoagain
Copy link
Contributor Author

@bitstein Monitoring Turbopack's progress on this issue sounds like a good idea. I'll be happy to translate any additional strings you add. Thank you for your efforts as well.

@bitstein
Copy link
Contributor

@sogoagain I updated a lot of translation strings on master. I believe I got essentially everything that is translatable.

@sogoagain
Copy link
Contributor Author

@bitstein I have added translations for the new strings. Thanks.

@bitstein
Copy link
Contributor

@sogoagain Thank you! One question I had looking at a few of the strings. I noticed "Satoshi Nakamoto Institute" is translated to "사토시 나카모토 연구소", which Google translates back to "Satoshi Nakamoto Research Institute". Is that simply an artifact of Korean vocabulary, or is there a more succinct name that more directly translates back to Satoshi Nakamoto Institute? I obviously trust your judgment more than Google, but was just wanting to understand.

@sogoagain
Copy link
Contributor Author

sogoagain commented Mar 23, 2024

@bitstein

Thank you for your feedback and question. I also spent a lot of time considering how to translate 'Satoshi Nakamoto Institute' into Korean.

In Korean, 'Institute' is typically translated as '협회(hyeop-hoe)', '학회(hak-hoe)', or '연구소(yeon-gu-so)'. Among these, '협회(hyeop-hoe)' implies an organization established and maintained by people with a common purpose, rather than for exchanging knowledge. It is used in terms like '환경협회(Environmental Association)' or '보건협회(Health Association)'. Therefore, I deliberated between '학회(hak-hoe)' and '연구소(yeon-gu-so)' and chose '연구소(yeon-gu-so)' for the following reasons:

  1. '학회(hak-hoe)' has a connotation of exploring academic knowledge, such as in '물리학회(Physical Society)' or '고분자학회(Polymer Society)', which are related to academic journals. While '연구소(yeon-gu-so)' also involves the exploration of deep knowledge, it comes across as less authoritative than '학회(hak-hoe)'. I believe that the knowledge surrounding Bitcoin and its creator, Satoshi Nakamoto, is not centrally authorized like academic journals, but rather knowledge that everyone creates together through discussion. That's why I translated it as '연구소(yeon-gu-so)'.

  2. I looked up several references related to this, and among them, the 'Mises Institute', which I frequently visit, is translated as '미제스 연구소(Mises yeon-gu-so)'. I thought 'SNI' had similarities in purpose and intent with the 'Mises Institute', so I translated it as '사토시 나카모토 연구소(Satoshi Nakamoto yeon-gu-so)'.

The Google translation result seems to be simply an issue with translating from Korean to English. This is because '연구소(yeon-gu-so)' can be translated as '(research) institute', '(research) laboratory', or '(informal) lab'.

If you think another translation would be better, I'd be happy to give it more thought. Please feel free to share your opinions! Thank you.

@bitstein
Copy link
Contributor

This is a phenomenal explanation, and I agree with your interpretations. SNI have more academic style writings and publications in the future, but its ultimate goal is indeed deep knowledge, widely accessible.

One of my selfish reasons for being excited about translations is getting to learn these sorts of linguistic facts.

@bitstein bitstein merged commit 28d4727 into NakamotoInstitute:master Mar 23, 2024
1 check failed
@bitstein
Copy link
Contributor

This is now live at https://nakamotoinstitute.org/ko

@sogoagain
Copy link
Contributor Author

Wow! Thank you so much. Really appreciate your effort in getting it live!

@bitstein
Copy link
Contributor

My pleasure! We made this, too:

image

@sogoagain
Copy link
Contributor Author

OMG! The Korean logo is so cool!!! 🚀

@sogoagain sogoagain deleted the application-strings-ko branch April 20, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants