• Hello,

    I am curious as to why Polylang does not work when using the WordPress translate functions (__(), esc_html__(), etc). For a theme to be able to run without Polylang enabled, it would require that every time a string needs to be translated in the template, you would need to do something like

    <?php echo function_exists('pll__') ? pll__('My string') : __('My string', 'my-domain') ?>

    Which seems a bit crazy.. Maybe I am missing something though.

    I see that the plugin has the plugins-compat.php file for 3rd party plugin support, so why does it not support a theme in a similar manner (possibly scanning theme for WordPress translation function calls like WPML does. and yes I already know of the existing plugin that does this, but it only works with the pll__ version and not the WP __() version)?

    Thanks very much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chouby

    (@chouby)

    Hi,

    I believe that you are mixing things. Of course __() is supported. There is even nothing special to do by Polylang with this function as WordPress is handling everything. So if you are using correctly this function, your theme will work correctly as every other themes.

    pll__() is an additional function added by Polylang to translate strings registered in the Strings translations panel. It is not meant to translate static strings, as __() does, but to translate dynamic strings generally stored in options. This function is useful only in a multilingual context. If you are familiar with WPML, it is the equivalent of the filter wpml_translate_single_string

    Thread Starter Corey Worrell

    (@coreyw)

    Okay, I guess what I expected is that I would be able to use __() throughout my theme, and then Polylang would allow me to edit the translations of those strings through the Strings translation page in the admin. Is this possible?

    I understand I can use the default .mo files, but those are not easily editable by the client, unless we install another separate plugin. But it seems this should be handled by Polylang.

    Thank you.

    Plugin Author Chouby

    (@chouby)

    Polylang is not a tool to translate po/mo files. Translating po/mo files is not only needed for multilingual websites but for all non-English websites. So it’s better to have dedicated tools. And there are good ones available for that such as Loco Translate or poedit.

    • This reply was modified 8 years, 6 months ago by Chouby.
    Thread Starter Corey Worrell

    (@coreyw)

    I don’t think we’re understanding each other.

    If a client is managing their website, they don’t care whether content is coming from the database or coming from a template, or what. They just want to translate anything that is shown on the website… So why should a user need to go to the Polylang String Translation page to edit certain strings there, but then need to use another plugin’s page to edit other strings?

    WPML handles this by searching the theme files for instances of __() and the like and letting you translate them through their String Translation page. Exactly like you would expect.

    I know you’re saying it’s not Polylang’s responsibility, but from a user’s standpoint, it really ought to be.

    Anyways, thank you for your help.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Why Does Polylang Not Use The Default WordPress Translate Function?’ is closed to new replies.