# Make Any Text Option Translatable With WPML

> Registers the text of selected site options, for example a plugin's notice text or a cookie banner message, in WPML String Translation and returns the right translation on the front end.

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

## Code

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

add_action( 'admin_init', function () use ( $wpide_options ) {
    if ( ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
        return;
    }
    foreach ( $wpide_options as $option ) {
        $value = get_option( $option );
        $hash  = md5( (string) maybe_serialize( $value ) );
        if ( is_string( $value ) && '' !== $value && get_option( 'wpide_wpml_opt_' . $option ) !== $hash ) {
            do_action( 'wpml_register_single_string', 'Site options', $option, $value );
            update_option( 'wpide_wpml_opt_' . $option, $hash, false );
        }
    }
} );

if ( ! is_admin() ) {
    foreach ( $wpide_options as $wpide_option ) {
        add_filter( 'option_' . $wpide_option, function ( $value ) use ( $wpide_option ) {
            return is_string( $value ) && '' !== $value
                ? apply_filters( 'wpml_translate_single_string', $value, 'Site options', $wpide_option )
                : $value;
        } );
    }
}
```

## Notes

Only works for options stored as plain strings. For array options, use WPML's own Admin Texts screen instead.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Make Any Text Option Translatable With WPML" 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/
