The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

pll_e best practices - documentation (3 posts)

  1. jjchinquist
    Posted 2 years ago #

    What is the best practice for using pll_e and pll__ ?

    My goal is that I would like to have many strings inside of my theme be translatable through the admin page. For example "Enter your search term.".

    Ideally I would register all _e('my-theme', 'some-string') and __('my-theme', 'some-string') calls in my theme to the admin interface. The wordpress-seo plugin registers its strings somehow automatically. How does it do that?

    If I simply place pll_e('my-theme', 'Enter your search term.'); in the theme templates, then I create a dependency of the theme on the polylang plugin. This could be bad if I need to disable polylang at any time - which will occur.

    I thought I could wrap all pll_e calls in a theme specific function called mytheme_e_($string) which is defined in function.php and will automatically add the context (e.g. 'my-theme') and check "if polylang is installed, then pll_e(...), otherwise e_(...). This method does create a lot of overhead but would allow me to remain flexible.

    It would be very helpful to add this documentation in the polylang readme or the polylang documentation pages. Thank you in advance!

    Additional resources:


  2. Chouby
    Plugin Author

    Posted 2 years ago #

    The wordpress-seo plugin registers its strings somehow automatically. How does it do that?

    That's pretty easy. You store your strings in an option (as you would do without any multilingual plugin), then create a wpml-config.xml file describing the options you want to translate. Thus you don't have to care if Polylang is activated or not.

  3. jjchinquist
    Posted 2 years ago #

    Thanks for the prompt reply, this is what I needed.

    When I have worked out a good options array for my theme, I will post it.

    It will be helpful in the future if you add it to the documentation site as a "Do this if you want to use the administrative forms to translate common words or phrases in the UI".

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic