Making Multilingual Site Title and Tagline on WordPress

September 8, 2014

Multilingual plugins of WordPress have different types, Bogo is good choice for “One language per post” type, which will be delivered to helping translate Site Title and Tagline for your WordPress website in this post.

At first, please add Bogo plugin to your WordPress and activate it.

Image

If you need more information about Bogo, please refer to the following site.

This post makes the multilingual site of two languages English and Japanese an example and translates the site title and the tagline(site description).

Specifically, the English site has “Design Hack and Slash” as site title, “Hopefully, there are some good ideas for you” as tagline, also the Japanese site has “デザイン ハック アンド スラッシュ” as site title, “きっと役立つ情報を わかりやすく記事にしよう” as tagline.

The method in this post is usable by other languages not only Japanese and English.

Why Bogo

Bogo does not create any additional custom table on your database, unlike some other plugins in this category. This design makes Bogo a solid, reliable and conflict-free multilingual plugin.
(from plugin’s description)

As for site title and site description, multilingualization must be reflected for SEO plugin in many cases because it is incorporated in header of html source, title tag and meta tag(name=”description”).

Bogo supports it well.
For example, the header of the html source is as follows.

html Source of the English Top Page (extract)

<html lang="en-US" prefix="og: http://ogp.me/ns#">
<head>
<title>Design Hack and Slash | Hopefully, there are some good ideas for you.</title>
<meta name="description" content="Hopefully, there are some good ideas for you."/>
...
<link rel="alternate" hreflang="en-US" href="http://designhack.slashlab.net/en/" />
<link rel="alternate" hreflang="ja" href="http://designhack.slashlab.net/" />
...
</head>

html Source of the Japanese Top Page (extract)

<html lang="ja" prefix="og: http://ogp.me/ns#">
<head>
<title>デザイン ハック アンド スラッシュ | きっと役立つ情報を わかりやすく記事にしよう</title>
<meta name="description" content="きっと役立つ情報を わかりやすく記事にしよう"/>
...
<link rel="alternate" hreflang="en-US" href="http://designhack.slashlab.net/en/" />
<link rel="alternate" hreflang="ja" href="http://designhack.slashlab.net/" />
...
</head>

It is a result using Bogo and WordPress SEO(by Yoast) plugins.
Check the following pages about hreflang if you need.

Let’s start.

Index of Steps

  1. Hook Functions to Insert Translation Processing for Site Title and Tagline
  2. Get Ready to Translate your WordPress Theme
  3. Add Translation Messages to Language File

Hook Functions to Insert Translation Processing for Site Title and Tagline

Add the following code to functions.php of your theme.

The hilighted line ‘yourtheme’ part appoints the text-domain (same as theme name in many cases) of your theme. If you do not know it, please rewrite it after the next step.

for Site Title

add_filter( 'option_blogname', 'tr_option_blogname' );

function tr_option_blogname( $blogname ) {
    return __($blogname, 'yourtheme');
}

for Site Description (Tagline)

add_filter( 'option_blogdescription', 'tr_option_blogdescription' );

function tr_option_blogdescription( $blogdescription ) {
    return __($blogdescription, 'yourtheme');
}

The parts which directly written site title or tagline in your theme are cannot be translated. Please use bloginfo() function instead of these.

Get Ready to Translate your WordPress Theme

Check Text-Domain of your Theme

Please search for the following code in functions.php, and if it is not found, add this code to top of file.

load_theme_textdomain( 'yourtheme', get_template_directory() . '/languages' );

The ‘yourtheme’ part is same as theme name in many cases.
You should use the same name that’s used the functions in the previous step. If it is different, please return and rewrite it.

Make “languages” Floder in your Theme Folder

  • wp-content/themes/yourtheme/languages

Create a .pot File in that “languages” Floder

  • wp-content/themes/yourtheme/languages/yourtheme.pot

The .pot file has no problem in empty at this time. Therefore, right click folder and click “New” > “Text Document” and rename created new file then it is OK.

If .pot, .po, or .mo files are already there, please backup them just to be safe.

Add Translation Messages to Language File

Edit .pot File

Please open the .pot file in your editor.

  • wp-content/themes/yourtheme/languages/yourtheme.pot

Add the following code to end of the file.

#: Site Title
msgid "Your Site Title"
msgstr ""

#: Site Description
msgid "Your Site Description (Tagline)"
msgstr ""

Input your site title and tagline into part of inside ” ” after msgid.

Even if English is not necessary for your site, message in msgid should be English, because a native language of WordPress is English. In fact, all translation on WordPress are from English into any language.

Generate Language File

With reference to the following site, and begin with step 2.1 for generating your objective language file.

To put it briefly, when scroll to end of translating window of Poedit, there are site title and tagline, please translate only these.

Change Site Title and Tagline to English

Finally, change the site title and the tagline to English via your WordPress admin panel.
Please open “Settings” > “General” panel, and change these, and click “Save Changes”.

Now, your WordPress Site Title and Tagline are Multilingualized!

Check each language version of your site, for example, it can do via following URLs.

  • http://yourdomain.com/ for default language
  • http://yourdomain.com/en/ for English version
  • http://yourdomain.com/de/ for German version

Default language means WordPress setting in wp-config.php, like this:

define ('WPLANG', 'ja');

In this case, default language is Japanese.
You can check out the following site to find your country and language codes.

The following URLs are each language version of my site.

Note of Caution

By way of example, change language of admin panel other than English by Bogo, and open “Settings” > “General” panel. You can see translated site title and tagline, but cannot change these translated messages here.

The set site title and tagline are absolutely English. Because it hook a get_option() function and inserted translation processing, translation is displayed. When you change the site title or the tagline or both, please carry it out in the following steps.

for Changing Translation

  1. Open the .po file in Poedit and change suitable parts and save it again.

for Changing English

  1. Open the .po file in your editor and change suitable msgid.
  2. Open the .po file in Poedit and save it again to update .mo file.
  3. Change suitable parts in the General Settings of WordPress admin panel.

Rerated Site

Thank you for enduring my poor English.
Hopefully, this post becomes the help to make your site better.

4 thoughts on “Making Multilingual Site Title and Tagline on WordPress

  1. Pingback: seo html

  2. kingstonphc.wordpress.Com

    I’m no longer certain the poace you’re getting your info,
    but great topic. I needs to spend a while studying more orr figuring out more.

    Thank you for wonderful information I used to be searching for this info for my mission.

    Reply
  3. Chris

    Thank you for this excellent tutorial. This was extremely helpful to me allowing me to achieve exactly what I wanted to do.
    I followed your steps to the letter and it really worked, allowing the translation of my site title and description to suit the translated pages of my added language.
    Bogo works very well but information/ documentaion of this calibre has been difficult to find. I don’t know if Bogo’s author Takayuki Miyoshi has ever read this tutorial perhaps you should consider sending him a link I’m sure he would be impressed.

    Thanks again,
    Chris

    Reply

Leave a Reply

Your email address will not be published.