This question seems extremely straightforward, but hours of googling have led to no results. Here's the basic gist:

I am building a site for Japanese viewers, and am using the theme's language folder to replace certain text (e.g. "Read More" and "Older Entries") with Japanese text. It works just fine when I set the WP language to Japanese in the admin; however doing so will mean that the English versions will NEVER display. I find it strange that WP allows me to do this for admins on a user basis, but not for the public facing website on a system language basis.

What I'm looking for is a solution that utilizes gettext and/or text domain to serve translated content only to those whose system language is set to Japanese, rather than a plugin solution. Frankly I don't see the point of using a translation plugin when the data has already been translated organically by myself in the theme .po and .mo files.

Note that the blog posts will already be in Japanese, and the site's customer base will be Japanese as well, so there is no real need for adding overhead to the database by adding a translation plugin. It would just be handy to have the default (English) text show for anyone who does not have their language set to Japanese. Previously I was using JS to just replace the strings that I needed, but of course that's an undesirable hack I would like to avoid.

*** I realize that it may seem silly to serve up English in an archive list of posts that are entirely in a different language; but I can see this having other practical applications, and some sort of solution may help others in the future. I also do a lot of work for clients in Asian countries and it would be useful to have a better grasp on how this might be achieved in a broader scope.

Any help would be much appreciated!

1 Answer 1


PHP can read the 'HTTP_ACCEPT_LANGUAGE' header from the browser request, but this might not be easy to parse if there is more than one accepted language set. For the simplest case, when one language is set as accepted, you need to read only first 2 characters from this header:

$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);

But, most WordPress language strings are more complex than that (there are few variations of English, and some languages have many variations too), so you would need to convert 2 letter language code into WordPress language code.

Also, HTTP_ACCEPT_LANGUAGE might not be included at all in the request, it depends on the browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.