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.

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

  5. Thanks! Solve this problem easily!

  6. Problem with viewing forms cause of & > < So use this

    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=20)) ? 1 : 2);

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

  8. Pingback: [워드프레스] 테마에서 po에디터로 번역할 문장 뽑아오는 방법 | 웹으로 말하기

  9. Pingback: [ワードプレス] テーマでPoeditに翻訳したいテキスト抽出する方法 | ウェブで話す

  10. Alexander Barrel says:

    I want to suggest another very efficient localization tool that pays special attention to plural forms: https://poeditor.com/. It works efficiently with translating strings, xlm, resx or po files and it gives extra benefits for translators such as translation memory and automatic translation.

    • hakre says:

      I find it not well named (the name is much too close to Poedit to my taste) and also there is no download link which means you need to outsource translation tools which is a big minus.

  11. Alexander Barrel says:

    Hi hakre, I understand your unpleasant feeling towards the name, but to me that is not important, but rather the practical benefits the program has to offer. Regarding the download link, this is a online translation tool that is used by project developers to work together with their translators. My point was that this hassle with setting the plural definition for a language is not for normal users, who barely use a software. Poeditor makes this directly when exporting your po or mo file from the translation made.

    • hakre says:

      I normally download online tools as well. Only they are intended for online use must not mean you can’t install them your own. Otherwise it’s only half a software.

  12. Pingback: PoEdit keywords - plurals - PHP Solutions - Developers Q & A

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 )

Google+ photo

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

Connecting to %s