拼湊傑夫

语言切换 // Switch of Language

刚弄了一点点的小修改,就是加了一个小切换的link在旁边。当你开启一个单独的post然后该post拥有双语的话,那么你就可以在右手边的一堆额外资料找到一个切换语言的link。点击它,你就会看到这个post的内容将会全部变成英文。其实也没什么大不了的东西,只是为了这个加入了隐藏/显示切换罢了。我并没有因为这样儿去安装插件,所以不要问我这个功能从哪里来,只需要很简单的javascript罢了。


if (document.getElementById('postTextEnglish') != null && document.getElementById('postTextMandarin') != null)
{
document.getElementById('postMetaSwitchLang').style.display = "block";
}
else
{
document.getElementById('postMetaSwitchLang').style.display = "none";
}

如我所说,我是用了很简单的方式去处理这件麻烦事情,从上面的程序片断就略知一二。我想上面的片断简单的不需要我在做任何解释了吧?

为什么我要去弄一个这样的东西出来,原因是从过去的post看得到,中文的部分,看起来已经相当多了,加上英文的内容简直就是完全长到不行,为了美观,我把英文的内容先行隐藏(我这个blog主要还是中文的)。这个目前应该算是临时的方案吧,或许下一次的界面更新会有一个更为成熟的方式去处理这样棘手的问题。看来这次的界面更新将会和之前一样,在运作的过程中一直有新的想法要加进来。是好事还是坏事呢?

I just made a small modification to this blog, i.e. I added a link for language switching at the right of the post in the individual post page. The link will be visible when there is a post (not posts prior to today) with both English and Mandarin content inside. I didn’t purposely install a plugin to do that but instead implement this using a simple javascript, so don’t ever bother to ask me what plugin I installed.


if (document.getElementById('postTextEnglish') != null && document.getElementById('postTextMandarin') != null)
{
document.getElementById('postMetaSwitchLang').style.display = "block";
}
else
{
document.getElementById('postMetaSwitchLang').style.display = "none";
}

As mentioned above, I chose the easiest solution as you see above. Just lines of code used, those code should be clear and simple enough to understand w/out any description.

The reason behind why I do this is because my posts in Mandarin is already quite lengthy (yes, I am grumpy), it is even worse when I have to mix it with English posts. Therefore, to make sure everything is tidy and nice, I hid this English section of post on load (this is more to a chinese blog anyway). This will be the temporary solution for the problem and hopefully I will be able to solve this problem better in the next update to the interface. 😀

Exit mobile version