abell
abell copied to clipboard
i18n out of the box
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)
Guess this is a great solution, but we will many files with that
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?
No, no, same website but separating translations into multiple files and load them on demand
oh yes makes sense
oh yeah! like what you show on the top, but need to add the code for each language in the documentation
There are two possibilities we can think of.
- 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.
- 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 ofhttps://overreacted.io/es/goodbye-clean-code
. This logic is probably handled by a Gatsby plugin namedgatsby-plugin-i18n
.
References
Yes 2nd method seems like a better option. Thank you for the help @kasipavankumar :D