Skip to content
Docs
Get RestroPress

Filter

wpml_translate_single_string

Updated
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#

ParameterTypeDescription
$valuestringThe original string.
$contextstringThe String Translation context.
$string_namestringThe registered string name.
$langstringThe 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), in rpress_wpml_translate_setting_value()
  • includes/plugin-compatibility.php (line 547), in rpress_wpml_translate_setting_value()
  • includes/plugin-compatibility.php (line 562), in rpress_wpml_translate_setting_value()
  • includes/plugin-compatibility.php (line 566), in rpress_wpml_translate_setting_value()

See also#

Was this page helpful?