Comments on: WordPress – Poedit: Translation Secrets https://www.cssigniter.com/wordpress-poedit-translation-secrets/ Premium WordPress themes, templates & plugins Wed, 15 Jul 2020 09:32:22 +0000 hourly 1 https://wordpress.org/?v=6.4.2 By: modelpaper2021 https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-263675 Wed, 15 Jul 2020 09:32:22 +0000 http://www.cssigniter.com/dev/?p=1759#comment-263675 Thanks a lot! You just helped me with the _nx function.
Thanks for the article!

]]>
By: Sioban https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-239468 Tue, 10 Mar 2020 13:37:53 +0000 http://www.cssigniter.com/dev/?p=1759#comment-239468 Thank you so much for your wonderful article ^-^ !

]]>
By: Adam Bergman https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-205461 Thu, 21 Jun 2018 09:08:23 +0000 http://www.cssigniter.com/dev/?p=1759#comment-205461 Great walkthrough! The list of keywords saved my day!

]]>
By: Carlos Mendoza https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-170153 Mon, 29 Feb 2016 11:44:09 +0000 http://www.cssigniter.com/dev/?p=1759#comment-170153 Thanks a lot! You just helped me with the _nx function.
Thanks for the article!

]]>
By: Anastis Sourgoutsidis https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-160171 Wed, 07 Oct 2015 22:12:40 +0000 http://www.cssigniter.com/dev/?p=1759#comment-160171 In reply to Caue Rego.

tl;dr
Assuming everything is set-up properly (e.g. plural form expression), I’d imagine you have multiple instances of the same text in your files, but only some of them are translated, or the domain does not match.

Long answer:

Consider these calls:
[php]
<?php
__( ‘One’, ‘domain’ );
_e( ‘One’, ‘domain’ );
_x( ‘One’, ‘context’, ‘domain’ );
__( ‘Many’, ‘domain’ );
_e( ‘Many’, ‘domain’ );
_x( ‘Many’, ‘context’, ‘domain’ );
_n( ‘One’, ‘Many’, 2, ‘domain’ );
?>
[/php]

They produce the following output inside the .po(t) file (generated by the latest version of Poedit at the time of writing).

[code]
#: functions.php:2 functions.php:3 functions.php:8
msgid "One"
msgid_plural "Many"
msgstr[0] ""
msgstr[1] ""

#: functions.php:4
msgctxt "context"
msgid "One"
msgstr ""

#: functions.php:5 functions.php:6
msgid "Many"
msgstr ""

#: functions.php:7
msgctxt "context"
msgid "Many"
msgstr ""
[/code]

If you follow the msgid and msgid_plural strings, you’ll make some observations. For example, you have 2 occurrences of “One” but 3 occurrences of “Many”, although in the PHP code above, each word appears exactly four times.
Obviously, the calls with a context create a new entry in the .pot file to differentiate from the calls without a context.
What is really interesting however, is that the first block that contains the _n() strings is grouped together with the first __() and _e() calls of lines 2-3, but there is separate block generated for the respective calls of “Many” in lines 5-6.
So, if there is any chance you (or the translator) skipped the translation of msgid_plural “Many” what exists in the .po file is probably this:
[code]
#: functions.php:2 functions.php:3 functions.php:8
msgid "One"
msgid_plural "Many"
msgstr[0] "Translated One"
msgstr[1] ""

#: functions.php:5 functions.php:6
msgid "Many"
msgstr "Translated Many"


[/code]
Now, if you called:
[php]_n( ‘One’, ‘Many’, 1, ‘domain’ );[/php]
would return Translated One

But if you called:
[php]_n( ‘One’, ‘Many’, 2, ‘domain’ );[/php]
would return Many

Assuming “Many” has been translated in the third block:
[php]
// Returns ‘Many’
_n( ‘One’, ‘Many’, 2, ‘domain’ );

// _n() returns ‘Many’.
// __() gets the value ‘Many’ as its first parameter, finds the third block (which is a match), and returns ‘Translated Many’
__( _n( ‘One’, ‘Many’, 2, ‘domain’ ), ‘domain’ );
[/php]
would seem to return the proper Translated Many, but as far as the whole gettext/WordPress thing is concerned, it’s a completely different string.

Hope this helps :)

]]>
By: Caue Rego https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-160159 Wed, 07 Oct 2015 16:39:56 +0000 http://www.cssigniter.com/dev/?p=1759#comment-160159 Do you happen to know what could make `_n()` properly choose the plural but not translating while `__(_n())` will work?

Also, as for the `_nx()` you probably know this by now, but just for the sake of it, [the documentation](https://codex.wordpress.org/Function_Reference/_nx) is pretty clear to me and confirms what you said there.

]]>
By: Bnimbhal https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-153334 Fri, 03 Jul 2015 09:43:47 +0000 http://www.cssigniter.com/dev/?p=1759#comment-153334 This is a great article, thanks a lot! I was going crazy trying to set up the _n function.

]]>
By: Pedro Góes https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-148793 Wed, 29 Apr 2015 15:56:01 +0000 http://www.cssigniter.com/dev/?p=1759#comment-148793 Very good and instructive text, thank you!

]]>
By: Anastis Sourgoutsidis https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-144944 Fri, 30 Jan 2015 17:00:51 +0000 http://www.cssigniter.com/dev/?p=1759#comment-144944 In reply to dekaelm.

Well, this depends on how you theme is built and how it’s translated (e.g. through plugins, .po/.mo files, etc).
Whoever set the site up for you, will be able to help.

]]>
By: dekaelm https://www.cssigniter.com/wordpress-poedit-translation-secrets/#comment-144909 Thu, 29 Jan 2015 22:16:12 +0000 http://www.cssigniter.com/dev/?p=1759#comment-144909 i must translate the script : “Διαβάστε περισσότερα” when i click English to “read more”. Same to the “αναζήτηση” to “Search”.
Can you help me please?
Thanks for your time
dekaelm

]]>