abell icon indicating copy to clipboard operation
abell copied to clipboard

i18n out of the box

Open saurabhdaware opened this issue 4 years ago • 7 comments

If we could have content like this,

content/
    |- my-cool-blog/
        |- index.md
        |- index_zh-Hans.md
        |- index_hi.md

so if a user prefers Mandarin, he will get content from index_zh-Hans.md (zh-CN is the code of Chinese Simplified)

saurabhdaware avatar May 24 '20 07:05 saurabhdaware

Guess this is a great solution, but we will many files with that

judicaelandria avatar Jun 20 '20 12:06 judicaelandria

yeah fair point, Have you seen any project handling i18n? I am a little clueless about this right now. Are there suppose to be two different websites for two different languages? or just the same website where you switch content with JavaScript?

saurabhdaware avatar Jun 20 '20 12:06 saurabhdaware

No, no, same website but separating translations into multiple files and load them on demand

judicaelandria avatar Jun 20 '20 13:06 judicaelandria

oh yes makes sense

saurabhdaware avatar Jun 20 '20 14:06 saurabhdaware

oh yeah! like what you show on the top, but need to add the code for each language in the documentation

judicaelandria avatar Jun 20 '20 16:06 judicaelandria

There are two possibilities we can think of.

  1. The site can have subdomains based on the language. For instance, the React Documentation's Hindi variant has hi.reactjs.org or Spanish variant has es.reactjs.org.
  2. When user requests for a translated page, it can be routed to respective language sub pages as can be seen at overreacted.io. For example, a post has URL of https://overreacted.io/goodbye-clean-code & Spanish version of the post has URL of https://overreacted.io/es/goodbye-clean-code. This logic is probably handled by a Gatsby plugin named gatsby-plugin-i18n.

References

kasipavankumar avatar Sep 07 '20 18:09 kasipavankumar

Yes 2nd method seems like a better option. Thank you for the help @kasipavankumar :D

saurabhdaware avatar Sep 07 '20 19:09 saurabhdaware