Skip to content

Instantly share code, notes, and snippets.

@yankiara
Created April 7, 2021 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankiara/3059be583ab6bbfe89fbe062f28e642e to your computer and use it in GitHub Desktop.
Save yankiara/3059be583ab6bbfe89fbe062f28e642e to your computer and use it in GitHub Desktop.
Polylang helpers and translatable strings
<?php
function plang() {
if ( function_exists('pll_current_language') )
return pll_current_language('slug');
else
return 'fr';
}
function phome() {
if ( plang() == 'fr' )
return '/';
else
return '/' . plang() . '/';
}
function pl__($string) {
if ( function_exists('pll__') )
return pll__($string);
else
return $string;
}
function pl_e($string) {
if ( function_exists('pll_e') )
pll_e($string);
else
echo $string;
}
if ( function_exists('pll_register_string') ) {
pll_register_string( 'projectname', 'A really interesting string to translate', 'projectname' );
pll_register_string( 'projectname', 'Another one', 'projectname' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment