Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

jjchinquist on "[Plugin: Polylang] pll_e best practices - documentation"

$
0
0

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:
http://wpml.org/documentation/support/wpml-coding-api/
http://polylang.wordpress.com/documentation/

http://wordpress.org/plugins/polylang/


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>