t('CCK')); case 'info': $info['cck']['refresh callback'] = 'i18ncck_locale_refresh'; return $info; } } /** * Makes safe keys for using in tt(). */ function i18ncck_get_safe_value($value) { return html_entity_decode(strip_tags($value), ENT_QUOTES); } /** * Refresh locale strings. */ function i18ncck_locale_refresh() { foreach (content_types() as $content_type => $type) { // Localization of CCK fields. if (isset($type['fields'])) { foreach ($type['fields'] as $field_name => $field) { // Localize field title and description per content type. tt('cck:field:'. $content_type .'-'. $field_name .':widget_label', $field['widget']['label'], NULL, TRUE); if (!empty($field['widget']['description'])) { tt('cck:field:'. $content_type .'-'. $field_name .':widget_description', $field['widget']['description'], NULL, TRUE); } // Localize allowed values per field. if (empty($field['allowed_values_php']) && !empty($field['allowed_values'])) { $function = $field['module'] .'_allowed_values'; $allowed_values = function_exists($function) ? $function($field) : (array) content_allowed_values($field); if (!empty($allowed_values)) { foreach ($allowed_values as $key => $value) { tt('cck:field:'. $field_name .':option_'. i18ncck_get_safe_value($key), $value, NULL, TRUE); } } } } } // Localization of CCK fieldgroups. if (module_exists('fieldgroup')) { foreach (fieldgroup_groups($content_type) as $group_name => $group) { tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':label', $group['label'], NULL, TRUE); if (!empty($group['settings']['form']['description'])) { tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':form_description', $group['settings']['form']['description'], NULL, TRUE); } if (!empty($group['settings']['display']['description'])) { tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':display_description', $group['settings']['display']['description'], NULL, TRUE); } } } } return TRUE; // Meaning it completed with no issues } /** * Translate widget's labels and descriptions. */ function i18ncck_content_field_strings_alter(&$field_strings, $content_type, $field_name) { $field_strings['widget_label'] = tt('cck:field:'. $content_type .'-'. $field_name .':widget_label', $field_strings['widget_label']); if (!empty($field_strings['widget_description'])) { $field_strings['widget_description'] = tt('cck:field:'. $content_type .'-'. $field_name .':widget_description', $field_strings['widget_description']); } } /** * Translate allowed values lists. */ function i18ncck_content_allowed_values_alter(&$allowed_values, $field) { foreach ($allowed_values as $key => $value) { $allowed_values[$key] = tt('cck:field:'. $field['field_name'] .':option_'. i18ncck_get_safe_value($key), $value); } } /** * Translate fieldgroup labels and descriptions. */ function i18ncck_content_fieldgroup_strings_alter(&$group_strings, $content_type, $group_name) { $group_strings['label'] = tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':label', $group_strings['label']); if (!empty($group_strings['form_description'])) { $group_strings['form_description'] = tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':form_description', $group_strings['form_description']); } if (!empty($group_strings['display_description'])) { $group_strings['display_description'] = tt('cck:fieldgroup:'. $content_type .'-'. $group_name .':display_description', $group_strings['display_description']); } }