Translating Plural Forms with Poedit

For your plugins: Last weekend I had a chat with Dion Hulse about how to make Poedit offer plural forms. It’s quite easy, just set it up:

Menu: Catalog -> Settings will open the Settings dialog. On the Project Info tab you find a Plural Forms edit at the bottom. Just put a plural form in here.

nplurals=2; plural=n != 1;

That was german, two plural forms.

nplurals=3; plural=(n%10==1 && n%100!=11) ? 0 : ((n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20)) ? 1 : 2);

That was russian, three plural forms.

Just press the OK button and Poedit will reflect the changes on entries offering plural forms:

poedit plural forms wordpress plugin revision control

Plural translations with Poedit

(Do not mind that the russian translation is missing, we actually figured that out so that the translator can use Poedit to start translating.)

Hopefully this will help others as well to get this running. When you close the file you might get an error-message. So it’s wisely to just close the file after the change of the setting and re-open it again. It then should work properly.

The good thing is with this little setting you can get the .pot files to work that you can download in your plugins admin section on wordpress.org if you’re a plugin author. Just browse to your plugins address and add admin at the end:

http://wordpress.org/extend/plugins/ your plugin name here /admin/

You can then obtain a .pot file there, the section is named Generate POT file.

Related: Additional functions for plural forms (gettext documentation section 11.2.6)

This entry was posted in Hakre's Tips and tagged , , , , , . Bookmark the permalink.

5 Responses to Translating Plural Forms with Poedit

  1. Pingback: 深圳林生英语翻译服务 » what cause the errors on Poedit

  2. Use the Codestyling Localization (WordPress Plugin) and you have no problems with plural in all languages. Works so fine in the backend of WP and poEdit is not necessary. [plugin is 100% compatible with poEdit]

  3. Jumbot says:

    Thanks for the tip!

    I was strugling with a French plural form (1 type).

    This worked although is keep getting an error.
    nplurals=2; plural=n;

  4. Pingback: Anleitung Theme Folio | Designers-Inn | Wordpress Themes. Tutorials. Wissen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s