# Polylang: Translate Plugin and Site Text Options

> Registers the text stored in selected options, such as a plugin's banner text or a footer notice, in Polylang's string translations and returns the translation on the front end.

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

## Code

```php
$wpide_options = array( 'my_plugin_notice_text' ); // Option names holding plain text.

add_action( 'init', function () use ( $wpide_options ) {
    if ( ! is_admin() || ! function_exists( 'pll_register_string' ) ) {
        return;
    }
    foreach ( $wpide_options as $option ) {
        $value = get_option( $option );
        if ( is_string( $value ) && '' !== $value ) {
            pll_register_string( $option, $value, 'Site options', false !== strpos( $value, "\n" ) );
        }
    }
} );

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

## Notes

Works for options that hold a plain string. Find option names in Tools > Site Health > Info or in the plugin's settings form field names.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Polylang: Translate Plugin and Site Text Options" 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/
