<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><id>https://blog.tusooa.xyz</id><title>css - 何事西风不待人</title><link href="https://blog.tusooa.xyz"/><subtitle>迷糊萝莉</subtitle><updated>2020-10-10T16:55:15.000Z</updated><entry><id>https://blog.tusooa.xyz/2020/10/10/Some-multilingual-hacks-on-Hexo/</id><title>Some multilingual hacks on Hexo</title><link rel="alternate" href="https://blog.tusooa.xyz/2020/10/10/Some-multilingual-hacks-on-Hexo/"/><published>2020-10-10T16:55:15.000Z</published><content type="html">&lt;div&gt; &lt;p&gt;I do not know why exactly I am so stubborn to insist on making this
site multilingual, and in a way that you may see multiple languages
at the same time. But it is something.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;我自己也不明白为什么我执拗得一定要把这网站做成多语言的，还是叫人
能同时看到多种语言的那种。但聊胜于无吧。&lt;/p&gt; &lt;/div&gt;
&lt;a&gt;&lt;/a&gt;
&lt;h1&gt;&lt;a href=&quot;#A-weird-thing-about-HexoHexo-的诡异事件&quot;&gt;&lt;span&gt; &lt;span&gt; A weird thing about Hexo &lt;/span&gt;&lt;span&gt; Hexo 的诡异事件 &lt;/span&gt; &lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;div&gt; &lt;p&gt;The &lt;em&gt;first&lt;/em&gt; weird thing I got, when I was trying to figure out
&lt;a href=&quot;https://github.com/next-theme/hexo-theme-next&quot;&gt;hexo-theme-next&lt;/a&gt;: sometimes &lt;code&gt;hexo server&lt;/code&gt; gives
the perfect result, but when I &lt;code&gt;hexo generate&lt;/code&gt; or &lt;code&gt;hexo deploy&lt;/code&gt;,
nothing will be correct. Everything is just malformed, and it
does not change even if I &lt;code&gt;hexo clean&lt;/code&gt;.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;我在折腾 &lt;a href=&quot;https://github.com/next-theme/hexo-theme-next&quot;&gt;hexo-theme-next&lt;/a&gt; 的时候碰到的第一个诡异事件是：
有时候 &lt;code&gt;hexo server&lt;/code&gt; 给出了个无懈可击的结果，但只要一 &lt;code&gt;hexo generate&lt;/code&gt;
或者 &lt;code&gt;hexo deploy&lt;/code&gt;，全完蛋。整个网站看着都非常诡异，甚至我
&lt;code&gt;hexo clean&lt;/code&gt; 了之后也没有丝毫变化。&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;After digging a lot into the source code, and enabling &lt;code&gt;--debug&lt;/code&gt;,
I finally found that there are some backup files that are also
processed. And the content of those files &lt;em&gt;does&lt;/em&gt; correspond to
the wrong contents on the site. &quot;Okay,&quot; hereby I say, &quot;this
behaviour is indeed ridiculous.&quot;&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;钻进源码里东张西望了好久，再合着 &lt;code&gt;--debug&lt;/code&gt; 的加成，我终于看到了一些备份文件
也被处理了。而其内容&lt;strong&gt;确然&lt;/strong&gt;是应了网站上有问题的东西。「行吧，」如是我说，
「是事直令人齿冷。」&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;And thus I added the ignore rules to ignore all such files,
and everything is hopefully back in place.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;所以我加了忽略规则来忽略这种文件，世界终于清净了，谢天谢地。&lt;/p&gt; &lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;ignore&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;  - &lt;/span&gt;&lt;span&gt;&quot;**/*~&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;  - &lt;/span&gt;&lt;span&gt;&quot;**/#*&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;  - &lt;/span&gt;&lt;span&gt;&quot;**/.#*&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;&lt;a href=&quot;#NexT-s-language-switcherNexT-的语言切换器&quot;&gt;&lt;span&gt; &lt;span&gt; NexT&apos;s language switcher &lt;/span&gt;&lt;span&gt; NexT 的语言切换器 &lt;/span&gt; &lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;div&gt; &lt;p&gt;That is an even more terrible part that comes in. Yes,
&lt;a href=&quot;https://github.com/next-theme/hexo-theme-next&quot;&gt;NexT&lt;/a&gt; comes with such a thing called a
&quot;language switcher,&quot; but it never takes you to a right
place. I cannot even get Hexo generate pages for
different languages, no matter how I change the &lt;code&gt;language&lt;/code&gt;
parameter in &lt;code&gt;_config.yml&lt;/code&gt;. So whenever I click on the
language switcher, I got a 404. And it is hidden at the very
bottom of the page --- How should one expect their visitor
to dig into the deepest hole before they can switch languages?&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;这玩意儿甚至更可怕了。是是是，&lt;a href=&quot;https://github.com/next-theme/hexo-theme-next&quot;&gt;NexT&lt;/a&gt; 有个叫「语言切换器」
的东西，但是它总把人引入歧途。让 Hexo 给不同的语言分别生成页面，这我
怎么改 &lt;code&gt;_config.yml&lt;/code&gt; 里的 &lt;code&gt;language&lt;/code&gt; 参数，也弄不成。所以呢，每次
按下这语言切换器的时候，404 就浮现在我眼前了。而且这切换器给藏在了页面
最底下——让访客钻进最深的洞里才许其切换语言，这能成吗？&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;So, well, since NexT&apos;s language switcher sucks, and multi-page
style multi-language implementation is not feasible, why not just
put everything all together? NexT at least provides a way to
customize what texts are shown... in &lt;code&gt;languages.yml&lt;/code&gt;.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;啊啊，行吧，NexT 这语言切换器是糟透了，多页面显示多语言也办不到，那么把
所有东西全放一起，这又如何呢？NexT 至少给了个用 &lt;code&gt;languages.yml&lt;/code&gt; 来控制
显示什么文字的方法呀......&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;The main idea is to merge NexT&apos;s default translations into one.
I made a Perl script for this. The text for every language is a
&lt;code&gt;span&lt;/code&gt;, and they are next to each other. Use css to put a divider
between every visible &lt;code&gt;span&lt;/code&gt;. Whether a language is shown is controlled
by a JavaScript program that adds or removes classes from the elements.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;大意就是把 NexT 的默认翻译全整一起去。这事我写了个 Perl 脚本去做。每种语言的文字
装在一个 &lt;code&gt;span&lt;/code&gt; 里，并并排。用 css 在每个显示了的 &lt;code&gt;span&lt;/code&gt; 之间，摆一个分割线。
至于某种语言是显示呢是隐藏呢，这让 JavaScript 程序来控制，就从元素里加上或是减去
些 class 就好。&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;As I am too lazy, the code is all &lt;a href=&quot;https://lily-is.land/tusooa/blog&quot;&gt;on GitLab&lt;/a&gt;.
Whether this is a viable implementation is left as an exercise
for the reader.&lt;/p&gt; &lt;/div&gt;
&lt;div&gt; &lt;p&gt;因为我太懒了，代码都在 &lt;a href=&quot;https://lily-is.land/tusooa/blog&quot;&gt;GitLab 上&lt;/a&gt;。这东西到底可行不，
留给读者作练习。&lt;/p&gt; &lt;/div&gt;</content></entry></feed>