# Polylang Translations for Customizer Settings

> Registers chosen Customizer text settings, such as footer copyright or a header phone number, in Polylang's string translations and shows the right translation in each language.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: polylang, customizer, strings
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pll-translate-theme-mods/

## Code

```php
$wpide_mods = array( 'footer_text', 'header_phone' ); // theme_mod names to translate.

add_action( 'init', function () use ( $wpide_mods ) {
    if ( ! is_admin() || ! function_exists( 'pll_register_string' ) ) {
        return;
    }
    foreach ( $wpide_mods as $mod ) {
        $value = get_theme_mod( $mod );
        if ( is_string( $value ) && '' !== $value ) {
            pll_register_string( $mod, $value, 'Theme mods', false !== strpos( $value, "\n" ) );
        }
    }
} );

if ( ! is_admin() ) {
    foreach ( $wpide_mods as $wpide_mod ) {
        add_filter( 'theme_mod_' . $wpide_mod, function ( $value ) {
            return is_string( $value ) && '' !== $value && function_exists( 'pll__' ) ? pll__( $value ) : $value;
        } );
    }
}
```

## Notes

List the theme_mod names in $wpide_mods, save the Customizer, then translate them in Languages > Translations under "Theme mods".

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Polylang Translations for Customizer Settings" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
