From my point of view, finding other alternative ways to translate a theme is not recommended and will be a setback in its popularity, as it will not allow users to add translations the same way they do for other themes and plugins.
For alternatives, see @PieterGoosens' answer. If you asked this because you found the process of adding i18n to your theme overly complicated, here's a step by step, using PO/MO/POT files. (So it doesn't actually answer your specific question, but might be helpful to those who need to add theme i18n). Assuming your theme is yourtheme
:
function load_yourtheme_theme_textdomain() {
$path = get_template_directory() . '/lang';
load_theme_textdomain( 'yourtheme', $path);
}
add_action( 'after_setup_theme', 'load_yourtheme_theme_textdomain' );
You will want to wrap the translatable strings in __()
function, using 'yourtheme'
as textdomain. For example:
echo __('Some text', 'yourtheme');
Here's a list of WP l18n wrappers
. Have a look a the the related functions on that page.
Now:
- Download and install Poedit. It's free.
- Open it, click
File
»New
. Choose default language.
- Save file as
.pot
in /lang
folder, inside your theme.
- Go to
Catalogue
»Properties
, add in the general details of your project. Use UTF-8.
- On
Sources Paths
(second tab), add ../
as base path.
- Click the second button in the row (the one that hovers "New Item") and add a single dot
.
as the path of your new item. Click Ok
to save the setting.
Catalogue
»Update from sources
.
The file will auto-grab all the translatable strings of your theme. Save again (make sure you save it as .pot
) and you're done.
If I skipped anything or you get stuck in any step, I'll update with details.
.mo
files in their own language and edit the translation without touching your.php
theme files. – tao Feb 3 '15 at 0:39