apply_filters( 'wpml_translate_string', string $string_value, string $string_name, (integer|array|object) $package )
- Type
- filter
- Category
- Retrieving Localized Content
- WPML Version
- 3.2
Description
*Retrieves a string translation. The filter looks up a string that is part of a package or a group of strings (as opposed to an individual string**). If it finds it, it looks for a translation in the current language. If a translation exists, it will return it. Otherwise, it will return the original string.
*To register a “package” string translation please see: wpml_register_string
**For retrieving an individual text string that does not belong to a package please see: wpml_translate_single_string
Note: This hook requires the WPML String Translation module
Arguments
- $string_value
- (string) (Required) The string’s original value
- $string_name
- (string) (Required) The string’s registered name
- $package
- (mixed) (Required) The string’s registered package identifier
-
- If $package is an array it needs to be associative and contain keys
kindandname. - If $package is an object it needs to have
kindandnamefields.
- If $package is an array it needs to be associative and contain keys
Example usage
A complete and detailed example can be found on the “String Package Translation” documentation page.
Related hooks
wpml_media_url, wpml_media_id, force_suppress_filters, wpml_get_translated_slug, wpml_home_url, wpml_translate_single_string, wpml_elements_without_translations, wpml_permalink, wpml_unfiltered_admin_string, wpml_element_link