diff --git a/metatag.i18n.inc b/metatag.i18n.inc new file mode 100644 index 0000000..7c3ad04 --- /dev/null +++ b/metatag.i18n.inc @@ -0,0 +1,18 @@ + t('Metatag'), + 'description' => t('Configurable metatags.'), + 'format' => FALSE, + 'list' => FALSE, + ); + return $groups; +} \ No newline at end of file diff --git a/metatag.inc b/metatag.inc index f079d29..321ad00 100644 --- a/metatag.inc +++ b/metatag.inc @@ -38,6 +38,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { } public function getValue(array $options = array()) { + $name = "metatag:" . $options["instance"] . ":" . $this->info["name"]; return $this->data['value']; } @@ -95,6 +96,8 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { } public function getValue(array $options = array()) { + $name = "metatag:" . $options["instance"] . ":" . $this->info["name"]; + $options += array( 'token data' => array(), 'clear' => TRUE, @@ -102,7 +105,7 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { 'raw' => FALSE, ); - $value = $this->data['value']; + $value = metatag_tt($name, $this->data['value']); if (empty($options['raw'])) { $value = token_replace($value, $options['token data'], $options); } @@ -182,6 +185,7 @@ class DrupalListMetaTag extends DrupalDefaultMetaTag { } public function getValue(array $options = array()) { + $name = "metatag:" . $options["instance"] . ":" . $this->info["name"]; $values = array_keys(array_filter($this->data['value'])); sort($values); return implode(', ', $values); diff --git a/metatag.info b/metatag.info index 4c97eca..540b4b1 100644 --- a/metatag.info +++ b/metatag.info @@ -4,6 +4,7 @@ package = Meta tags core = 7.x dependencies[] = token dependencies[] = ctools +dependencies[] = variable configure = admin/config/search/metatags files[] = metatag.inc diff --git a/metatag.module b/metatag.module index ce1514c..312e5f3 100644 --- a/metatag.module +++ b/metatag.module @@ -234,6 +234,16 @@ function metatag_config_save($config) { // Allow modules to alter the configuration before it is saved. module_invoke_all('metatag_config_presave', $config); + // Update the i18n string + if (function_exists('i18n_string_update')) { + $instance = $config->instance; + + foreach ($config->config as $field => $item) { + $name = "metatag:" . $instance . ":" . $field; + i18n_string_update($name, $item['value']); + } + } + if ($config->is_new) { drupal_write_record('metatag_config', $config); module_invoke_all('metatag_config_insert', $config); @@ -465,6 +475,8 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti $options['language'] = isset($languages[$options['language']]) ? $languages[$options['language']] : NULL; } + $options['instance'] = $instance; + foreach ($metatags as $metatag => $data) { if ($metatag_instance = metatag_get_instance($metatag, $data)) { $output[$metatag] = $metatag_instance->getElement($options); @@ -486,6 +498,8 @@ function metatag_metatags_values($instance, array $metatags = array(), array $op $options['language'] = isset($languages[$options['language']]) ? $languages[$options['language']] : NULL; } + $options['instance'] = $instance; + foreach ($metatags as $metatag => $data) { if ($metatag_instance = metatag_get_instance($metatag, $data)) { $values[$metatag] = $metatag_instance->getValue($options); @@ -518,6 +532,7 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( $options += array( 'token types' => array(), 'defaults' => metatag_config_load_with_defaults($instance), + 'instance' => $instance, ); $form['metatags'] = array( @@ -907,6 +922,7 @@ function metatag_get_instance($metatag, array $data = array()) { function metatag_get_value($metatag, array $data, array $options = array()) { $value = ''; if ($metatag_instance = metatag_get_instance($metatag, $data)) { + $options["instance"] = $metatag; $value = $metatag_instance->getValue($options); } return $value; @@ -1109,3 +1125,16 @@ function metatag_config_access($op, $config = NULL) { return FALSE; } + +function metatag_tt($name, $string, $langcode = NULL, $update = FALSE) { + if (function_exists('i18n_string')) { + $options = array( + 'langcode' => $langcode, + 'update' => $update, + ); + return i18n_string($name, $string, $options); + } + else { + return $string; + } +}