Skip to content

Instantly share code, notes, and snippets.

@davekiss
Last active June 19, 2016 21:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davekiss/a3f58ae284bde8397cb6 to your computer and use it in GitHub Desktop.
Save davekiss/a3f58ae284bde8397cb6 to your computer and use it in GitHub Desktop.
Localizing and Translating WordPress Plugins

1. Load the Text Domain

add_action( 'init', array($this, 'vimeography_load_text_domain') );

public function vimeography_load_text_domain() {
  load_plugin_textdomain('vimeography', false, dirname( VIMEOGRAPHY_BASENAME ) . '/languages/');
}

2. Localize Strings

__('Edit Settings', 'vimeography)

3. Open POedit

  • File->New
  • Select base plugin language (E.G., English)
  • File->Save as vimeography.pot
  • Catalog->Properties
  • Add project name, email address
  • Add Sources Paths (E.G., Base path: ../ and Paths: .)
  • Add Sources Keywords __ and _e

4. Add Translations and Save file

German: vimeography-de_DE.po

This will automatically generate the vimeography-de_DE.mo file as well.

5. Download the WP language file

You can find this at the WordPress language repository. http://i18n.svn.wordpress.org/ de_DE/trunk/messages/de_DE.mo

Save it to wp-content/languages/

6. Add the language to wp-config.php

define('WPLANG', 'de_DE');

To Update Strings

Open the vimeography.pot default translation file in POedit and choose Catalog->Update from Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment