Introduction
WPTouch is a popular WordPress plugin that allows you to display your site’s content on mobile devices. It can send mobile-optimized content, pictures, scripts, and CSS code instead of ‘normal’ ones. This speeds things up considerably. It also allows your iOS visitors to save your website like an app.
WPTouch works great with WPML. In this tutorial, we will explain how to translate text that comes with WPTouch themes and extensions.
What You Will Need:
- A recent version of WPML, including the String Translation and Translation Management add-ons
- The WPTouch plugin
- One of WPtouch’s extensions (We use the Mobilestore theme in this tutorial)
Essential Resources:
- WPML’s Getting Started Guide will help you in setting up WPML in only a few minutes. You will want to refer to some of its subtopics later, such as Theme and Plugin Localization and String Translation. We recommend you keep the Getting Started Guide open while following this tutorial.
- WP Touch documentation has an excellent collection of tutorials that can help you get started.
Translating Strings Coming from WPTouch Themes and Extensions
WPTouch allows one-click downloading and installation of additional themes and extensions. The extensions are saved in wp-content/wptouch-data. As you can see, this path is outside the default plugin directory. WPML String Translation scans everything inside the themes directory (wp-content/themes) and the plugins directory (wp-content/plugins). We will create and import .po files into the String Translation table so you can translate these strings with WPML.
First, make sure you enabled theme and plugins localization in WPML, You can do that by going to WPML > Theme and plugin localization, then choosing “Translate the theme and plugins using WPML’s String Translation.”
The Mobilestore theme, which is a WPTouch extension, does not come with a .po file, so we must create one.
Obtain zipped theme files from your site after it is downloaded using the WPTouch installer. This can be done by following these steps:
- Go to the WordPress directory.
- Then, go to wp-content/wptouch-data/themes.
- Locate the theme folder. In our case, it will be the “mobilestore” folder.
- Download the mobilestore files and compress them with a .zip extension.
The second step is to create our .po file:
- After getting the zipped theme file, you can extract strings and export .po files using various tools. ICL PHP Scanner will do the trick. http://www.icanlocalize.com/tools/php_scanner
- Upload the zipped file by clicking on the “Browse…” button next to “PHP file to process (required)”:.
- Click on the ”Create .po file >>” button. This creates the wptouch-pro.po
Once you have the wptouch-pro.po file, upload it to your site using the WPML String Translation screen. Remember to assign the correct context for imported strings (if the wptouch-pro context is missing, create a new context with that name).
- Go to WPML >> String Translation >> Import / export .po section.
- Next to “.po file”:, click the ”Browse…” button and upload the wptouch-pro.po
- Choose “Also create translations according to the .po file.”
- Choose the string domain from the drop down menu next to “Select what the strings are for:” Note that you can create a new domain by clicking on “new” then typing the domain name (wptouch-pro).
- Click on the “Submit” button
After the upload is finished, you will be redirected to the string selection screen. Select all the strings you want to translate, then click on “Add selected strings.”
After importing the strings, registered strings which are ready to be translated can be found on the WPML >> String Translation screen. Note that you can find all the strings under the wptouch-pro domain.
Conclusion
Creating .po files and importing them into WPML String Translation tables will register the strings to be translated on the string translation screen. This can only be done when the installed plugin, theme or extension has its own directory (not under the default directory).