Bỏ qua điều hướng
0

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:

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.”

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:

  1. Go to the WordPress directory.
  2. Then, go to wp-content/wptouch-data/themes.
  3. Locate the theme folder. In our case, it will be the “mobilestore” folder.
  4. Download the mobilestore files and compress them with a .zip extension.

create .po file1

The second step is to create our .po file:

  1. 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
  2. Upload the zipped file by clicking on the “Browse…” button next to “PHP file to process (required)”:.
  3. Click on the ”Create .po file >>” button. This creates the wptouch-pro.po

create .po file2

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).

  1. Go to WPML >> String Translation >> Import / export .po section.
  2. Next to “.po file”:, click the ”Browse…” button and upload the wptouch-pro.po
  3. Choose “Also create translations according to the .po file.”
  4. 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).
  5. Click on the “Submit” button

add .po file to string translation

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.”

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.

string translation

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).