## 通过截获gettext调用来修改WordPress的部分翻译

1. 创建一个child theme。
2. 在child theme的functions.php中加入如下代码：
function change_attribute_line( $translated_text,$text, $domain ) { switch ($text ) {
$translated_text = __( '低调地使用%s'); break; } return$translated_text;
}


## Replacing WordPress translation by hooking to gettext

In a typical WordPress website, you see this line in the page footer:

This line links to WordPress website. The official Chinese translation of this line is:

“自豪地采用WordPress”

I’m using WordPress in several of my websites and I found it’s annoying: It’s a word to word translation and it’s simply not what we Chinese would say when we want to attribute something to someone. After some thinking, I think the appropriate translation should be:

“采用”emphasis the choosing of WordPress, “使用”emphasis the fact we are using WordPress right now.

The message is clear and typical Chinese: I’m a humble webmaster. All the glories go to WordPress.

So I set out to change the translation. It turned out to be rather complicated, but here’s how I finally accomplished it:

1. Create a child theme of your current theme, because you’ll have to rewrite its logic and you don’t want your effort to be overwritten by an upgrade of that theme. The procedure of creating a child theme can be found here.
function change_attribute_line( $translated_text,$text, $domain ) { switch ($text ) {
$translated_text = __( '低调地采用%s'); break; } return$translated_text;
}


That’s it.

Notice that I search for $text instead of$translated_text. You can also search for $translated_text. That would be:  switch ($translated_text ) {
case '自豪地采用%s' :
$translated_text = __( '低调地使用%s'); break; } return$translated_text;


I search for \$text because I assume (I’m not sure) search for non-unicode string will be faster.

It’s worth noting that both strings have placeholders in it. Initially I was trying to search the whole string, “Proudly powered by WordPress” or “自豪地采用WordPress” and failed. The fact that the above code works tells us, gettext() and its filters are called before the placeholders get replaced. I spent a lot of time figuring this out. It’s not mentioned in the document, nor did anyone post this on the web. This is actually the key reason why I write this post. Someone from WordPress should update the document.

## 中国古诗文

• 在内容上，以原文为本。不要译文，基本没有注释。
• 在布局上，以内容为主，去除一切干扰因素。要求干净，大方。
• 各古诗文名家作者就是blog作者，既直观有趣，又方便组织。

1. 开发批量插入作者的功能——已完成；
2. 开发批量插入帖子的功能——已完成；
3. 建立分类目录：需要专业人员帮助。
4. 开发新的数据结构以存储传统计时方式：朝代，年号，年号纪年，公元纪年，季节，时令，时辰。
5. 扩展帖子属性，其中帖子发表时间采用新的数据结构。
6. 扩展作者属性，其中作者生卒时间采用新的数据结构。
7. 修改界面，使帖子能够显示传统计时（年号，天干地支）。

## Blog move done

Finally completely moved all my blog posts from the original blogspot site to my own server.

All posts are here now and the original site:

http://retidigca.blogspot.com/

is deprecated now.

Still a lot of topics were started but haven’t been completed. I will try to put some existing draft online recently.

## identified factors that benefits cognitive development in children

After reading years of Scientific American on this topic, these 4 are the factors I identified that are beneficial in cognitive development forchildren. I just put it here for future reference.

• Physical Exercise
• Handiwork, Hand-eye coordination
• Sleeping
• Multi-language environment

## building self-aware device – part 2

After about 15 months, here’s part 2. You can see part1 here: building self-aware device – part 1

So now we define self-awareness as:

1. Knows ones own properties and boundary;
2. Able to learn ones own identity from self-initiated training;

Can we build device that is self-aware? After some thought, we have to say, achieving the most general sense of item 1 is way beyond our reach. Animals learn its own properties and boundary (again) through learning. The learning process correlates the visual signal from eyes,  touch signal from sensors covering the whole body, signals from motor neurons and maybe more. We might be able to build an artificial eye, but currently there’s no technology that come close to a distributed sensing system like the skin and the fur, or a distributed control system like the muscle.

But, if we limit our device to have a rigid body, then it becomes something we can handle, at least to a certain extent.

If the 3D model (the shape, the size) of the rigid body is known. Then with a GPS receiver installed in a fixed point within the rigid body, and a gyroscope to tell the orientation of the device, we basically have a device that knows it’s own properties and boundary. (In our simplified case, both the properties and the boundary are static. Properties are whatever inside the rigid body, boundary is the boundary of the rigid body.)

Following this approach, we might be able to add some moving parts into this rigid body gradually.

<Here further expansion is needed>

Then let’s move to the next step. Let’s put it in front of a mirror. The device has to start some random movement, and then correlate the movement with the movement it sees in the mirror.

For that we need a neural network, the input would be, on the one hand, the instructions for the random movement and on the other hand, the actual movement it sees in the mirror. So this becomes a supervised learning problem.

So we see that building self-aware device is still a long way to go. However, I believe we should be able to experiment it in controlled scenarios, like fully automated driving, and try to push the limit to see how far can we go.

## Computer, another origin

When talking about computer origin, people tend to think about chips, CPU, world war II and ENIAC, and in some occasions, date back to slide rule and Suanpan. This is also how it is taught in schools and universities. The logic behind this story line is, computer originated from the need for fast computing, especially arithmetic computing.

However, there’s another origin that is at least as important, has a longer history, and at least to some people, more fascinating. That is how the architecture of modern computer came into being. Computer nowadays is so powerful that sometimes it seems inconceivable to link it to its ancient ancestors. On the other hand, you only have to look into some of the remarkable masterpieces of the past to know the linkage is simply undeniable.

A recent BBC program I watched, “Mechanical Marvels – Clockwork Dreams” showed one of such remarkable masterpieces: A mechanical machine boy that is able to write up to 40 letters of text, depending on the configuration, built back in 1770s.

What makes it remarkable is, the text is customizable. That means, the machine boy is programmable.

Of course, it’s still an Finite State Machine, but being programmable, that means adding scratch memory to it and then it will be a complete Turing Machine!

It’s actually from this origin where techniques were developed for modern computer scientists to deal with abstract topics like computational complexity, formal language.