Goal
After setting my personal site up I wanted it to be translatable to Japanese so this will be my documentation on creating a translatable version of my site.
After setting my personal site up I wanted it to be translatable to Japanese so this will be my documentation on creating a translatable version of my site.
The construct from what i have read and seen is that Jekyll's parser needs to read a JSON file and from my main.js it can toggle between ENG and JPN on every site, and be kept on the chosen language until switched. Even after selecting the language, going back to the site index will remain on the language same selected language becuase of localStorage.
This was something new to me, at least the name. Its stored in structured formats like JSOn and YAML. Interestingly form what i read it also does specific locale information like Date and time formats which was kinda neat.
Thats it just these three sections, but they will spread across the entire site, so they will be added as an "includes" all thanks to Jekyll ๐
const i18n = {
currentLang: localStorage.getItem('siteLang') || 'en',
translations: {},
...
};
For this to work, EVERYTHING MUST CHANGE *sigh Thats just the way it is
To make this page translatable using the data-i18n system, everything must be translated with data-i18n attributes. Letโs break down your HTML and see what needs it.
<h1 data-i18n="greeting" style="margin-bottom:25px;">Greetings!</h1>
<div class="insight">
<h4 data-i18n="welcome_message">Welcome to my personal blog spot</h4>
<p data-i18n="intro_text">
Here on this site you will get to know who I am and what...
<a href="https://packetpluckers.com" target="_blank"><span class="href" data-i18n="main_site">PacketPluckers.com</span></a>.
</p>
<p data-i18n="contact_invite">So please have a look around, and if you'd like, get in contact to exchange ideas or projects.</p>
<p data-i18n="signature">- kind regards</p>
</div>;
{
"siteTitle": "My Portfolio",
"welcomeMessage": "Welcome to my site!",
"aboutMe": "About Me",
"contact": "Contact",
"projects": "Projects"
}
{
"siteTitle": "็งใฎใใผใใใฉใชใช",
"welcomeMessage": "็งใฎใตใคใใธใใใใ๏ผ",
"aboutMe": "่ชๅทฑ็ดนไป",
"contact": "ใๅใๅใใ",
"projects": "ใใญใธใงใฏใ"
}"