Skip to content

Instantly share code, notes, and snippets.

@abelsaad
Last active August 1, 2021 09:47
Show Gist options
  • Save abelsaad/5fc5eb236174b053b5773b3fc6f05163 to your computer and use it in GitHub Desktop.
Save abelsaad/5fc5eb236174b053b5773b3fc6f05163 to your computer and use it in GitHub Desktop.
Polylang: Translate custom strings
You must first register the strings for translation.
For example you echo "Hello world" in some template file like this:
<?php pll_e('Hello world'); ?>
To show string in the "Strings translation" add in your functions.php:
<?php
add_action('init', function() {
pll_register_string('mytheme-hello', 'Hello world');
});
?>
Add all custom strings you want to translate to this function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment