Let’s make a page translated by bogo [2 languages]


Let’s make a translated version of your own HP using bogo. bogo is not an automatic translation tool. It will create a directory for translation.

I can’t think of what I want to write

I’m sorry for the cat diary.
It seems that he had somehow suffered from Sabori disease in the summer.
I can’t think of what I want to write → Articles don’t increase
That’s a negative loop.

With this, you will never be able to reapply for Google Adsense.
Although it is a painstaking measure, I would like to publish translated articles and double the number of articles.

Let’s use bogo

There are quite a lot of translation tools in wordpress, but after looking at them, bogo seems to be good, so I will use this one this time.

There is a great plugin that translates automatically, but if you add English, for example, this plugin will do it for you.


It has a structure like a subfolder like

This seems to be good for SEO, so I’m grateful.
Let’s install it.

Nothing in particular changes when you enable it.
bogo works best after adding an article.

Translate the basic parts

We will translate the basic parts such as tags and titles.
However, depending on the theme, there are parts that are not completely translated, so I will rewrite those parts with PHP or javascript.
For the time being, bogo will handle the basic part, so let’s open bogo.

When bogo is enabled, a menu called Language will appear.

There are 127 languages ​​to choose from, but this time I’ll leave it to English only.
If you have other languages ​​you want to add, you can add them with just one click.

We will set the English page.
A menu to translate the text will appear in the language section, so click it.
Then, a menu that translates and displays with bogo will appear.

I will translate the sentences in the translation into English.
Yes, you set it yourself.

You might expect automatic translation, but unfortunately bogo is not an automatic translation tool.
You can dare to leave it in Japanese, or you can translate tags that are slightly different in terms of nuance.
For the time being, I will fill in here.

The tags and categories are now translated.
Try typing your address /en /.

This is automatically translated only when /en /is attached.
However, the important titles etc. have not been translated.
I don’t know if this is a bogo spec or a cocoon spec, but I’ll change the title in PHP.

That’s my idea, but I think it’s okay to change the others quickly with jquery, but if you do not change the title before displaying it, it will be displayed as a Japanese name in the search, so it is meaningless I think.

So I will change only the title with PHP.
Nice thing, there are some cocoon users who have already tried it, so I will refer to it.

WordPress サイトタイトルとキャッチフレーズを英語にする方法

I will borrow the program inside and rewrite it for myself.

//Read the text data after language conversion
function translateHeader () {
//———————————————— ——————————-
//—— !! Test for direct language conversion !!-All BOGO languages ​​are also switched. !! ———
//———————————————— ——————————-
//from here
$ lang= get_bloginfo (‘language’);//Japanese switching
if ($ lang==’ja’) {
update_option (‘blogname’,’goro sleep’);
update_option (‘blog description’,”);
//English switching
elseif ($ lang==’en-US’) {
update_option (‘blogname’,’gorone’);
update_option (‘blog description’,’Cat is relaxing and sleeping’);
//Template for adding multiple languages
elseif ($ lang==’○○ word’) {
update_option (‘blogname’,’changed title’);
update_option (‘blog description’,’changed tagline text’);
} * /

//So far
//———————————————— ——————————-
//—— !! Test for direct language conversion !!-All BOGO languages ​​are also switched. !! ———
//———————————————— ——————————-

function localize_title () {

//Language switching function call
translateHeader ();

function set_after_parent_theme () {
add_filter (‘pre_get_document_title’,’localize_title’);

add_action (‘after_setup_theme’,’set_after_parent_theme’, 10);

I will write this in functions.php of the child theme.
How is the result?

It switched properly!
We have added explanations only in English, and the explanations will not accept complaints!

Now that the title has changed, I’d like to add a paragraph, but the sidebar etc. have not been translated yet.
bogo can also switch the sidebar etc. depending on the language.

You can switch the display between Japanese and English.
If you use this and categories well, you can create a page entirely for that language.

I haven’t added any English articles yet, so I’m leaving it for now.
By the way, it seems that the /en /page automatically adjusts so that only English articles are displayed on the top page.

I’ve just made a translated version of this article, so I’ll continue writing.
First, let’s change the horizontal blog parts into translated ones.
For places that can be easily changed with PHP like this, it is probably better to use PHP functions.

Is this a translation of the bulletin board?
Please let me know if you are a native person!

It seems better to change the new card etc. here, but change the new card widget itself.
Because when I tried it with cocoon’s custom code, I saw that the English version was displayed only in English, so it was an experiment.

Experimental result:

New articles went well, but popular articles didn’t.
I wonder if it can be done.
I don’t know if it happened that new articles were also categorized by language, or if I aimed at them, but it seems to be a coincidence.

I was a little worried, but decided to divide it into categories.

It seems that it can be separated by the original function of wordpress, but it is a simple method because it is expensive to make one function such as counting and issuing cards.

Although new articles are working, I don’t know when they will fail, so I decided to show and hide them by category.
The list in the sidebar has grown a bit, but be patient as it only appears in that language.

This method seems to be strict if you use many languages.
In that case, it seems good to put it in and out depending on the language and change only the display with javascript.

After that, I’ll let you go with brute force

By increasing the number of categories, the category column has increased.
Of course, you can narrow down the display of categories and change the display /non-display with widgets, but I don’t want to increase the sidebar menu anymore! (Mysterious commitment)

That’s why I will erase it with gorigori javascript.
* Maybe it is better to manage it with a widget.

You can rely on the user’s PC power for a while.
That’s why I will change various untranslated parts.

Even if it is an English page like this, there are parts that have not been translated yet, so let’s change the display with jQuery.
For the time being, I switched where I could.

var lang= location.href; //English //
if (lang.indexOf (‘en’)!== -1) {
$ (‘. Breadcrumb-home’). Children (‘a’). Text (‘HOME’);
$ (‘.toc-title’). text (‘contents’);
//$ (‘.toc-title’). Attr (‘[close]’,'[close]’);
$ (‘. Hatebu-button’). Children (‘span.button-caption’). Text (”);
$ (‘.copy-button’). Children (‘span.button-caption’). Text (‘copy’);
$ (‘.ad-label’). Text (‘Sponsoring’);
var readtime= $ (‘.read-time’). Children (‘span.bold’). Text ();
readtime= readtime.replace (“about”,””);
readtime= readtime.replace (“minutes”,””);
$ (‘.read-time’). html (`This article can be read in about $ {readtime} minutes.`);
$ (‘. Author-description’). Children (‘P’). Html (‘My cat. I cry right away and get angry right away. Tiny.’);
$ (‘.sns-share-message’). text (‘Share’);
$ (‘.sns-follow-message’). text (‘Follow gorori’);
$ (‘.related-entry-main-heading’). text (‘Related article’);
$ (‘#comments’). Text (‘comments’);
$ (‘# comment-reply-btn’). text (‘Write a comment’);
$ (‘.search-box’). Children (‘input’). Attr (‘placeholder’,’search’);
$ (‘.cat-item-20’). remove ();
$ (‘.cat-item-11’). remove ();
$ (‘.cat-item-14’). remove ();
$ (‘.cat-item-3’). remove ();
$ (‘. Author-widget-name’). text (‘Pet cat’);

What is disappointing is [Close] and [Open] in the table of contents.
I thought that jQuery could do anything, but when I close it, it opens itself as a pseudo element and does not have a DOM, so it seems that it can not be overwritten easily.

It seems that it will be rewritten when you search, but it will take a little longer.
For the time being, I tried to translate the part that can be translated this time.

Close … I want to translate it someday.

Amazon.co.jp: jQuery最高の教科書 eBook : 株式会社シフトブレイン: 本
Amazon.co.jp: jQuery最高の教科書 eBook : 株式会社シフトブレイン: 本