Filter
wpml_translate_single_string
On this page
Calls WPML String Translation to translate a RestroPress setting value.
RestroPress applies this WPML filter in rpress_wpml_translate_setting_value() to look up the translation of a setting string (or of each string inside an array setting) for a target language. The string name has the form '[rpress_settings]key' and the context is 'admin_texts_rpress_settings'. If nothing is translated, a second lookup is made with the 'admin_texts_rpress_settings-en' context and the '[rpress_settings-en]key' name, and then the per-language rpress_settings-{lang} option is tried.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$value | string | The original string. |
$context | string | The String Translation context. |
$string_name | string | The registered string name. |
$lang | string | The target language code. |
Return value#
string. The translated string, or the original when no translation exists.
Example#
add_filter( 'wpml_translate_single_string', 'my_translate_setting_string', 10, 4 );
function my_translate_setting_string( $value, $context, $string_name, $lang ) {
if ( 'admin_texts_rpress_settings' === $context && 'de' === $lang && 'Order received' === $value ) {
return 'Bestellung erhalten';
}
return $value;
}
Notes#
Fired from four places in rpress_wpml_translate_setting_value(): once per string (primary and -en context) for array settings and for scalar settings.
Source#
Applied in:
includes/plugin-compatibility.php(line 543), inrpress_wpml_translate_setting_value()includes/plugin-compatibility.php(line 547), inrpress_wpml_translate_setting_value()includes/plugin-compatibility.php(line 562), inrpress_wpml_translate_setting_value()includes/plugin-compatibility.php(line 566), inrpress_wpml_translate_setting_value()
