function webform_localization_translate_select_option in Webform Localization 7.4
Translate a single option from component.
Parameters
array $component: The select component
string $option: Untranslated option string.
Return value
string The translated option string, if found.
2 calls to webform_localization_translate_select_option()
- _webform_localization_csv_data_select in components/
select.inc - Implements _webform_localization_csv_data_component().
- _webform_localization_csv_header_select in components/
select.inc - Implements _webform_localization_csv_header_component().
File
- components/
select.inc, line 19 - Webform localizations for select component.
Code
function webform_localization_translate_select_option($component, $option) {
// Find the source for data value and translate it.
$item_key_lookup = _webform_localization_string_to_key($component['extra']['items']);
foreach ($component['extra']['translated_strings'] as $name) {
$name_list = explode(':', $name);
// Translate options.
if (strpos($name_list[3], '-') !== FALSE) {
list(, $key) = explode('-', $name_list[3]);
if (isset($item_key_lookup[$key]) && $option == $item_key_lookup[$key]) {
return i18n_string($name, $option);
}
}
}
return $option;
}