You are here

function metatag_translations_update in Metatag 7

Update the translated definitions of meta tags.

Parameters

array $metatags: List of meta tags to have their translations updated.

string $context: The string that will be used to group strings in the translation UI.

5 calls to metatag_translations_update()
i18n_string_metatag_config_insert in ./metatag.module
Implements hook_config_insert().
metatag_context_config_add_form_submit in metatag_context/metatag_context.admin.inc
FormAPI callback to save the 'edit_name' form.
metatag_context_config_edit_form_submit in metatag_context/metatag_context.admin.inc
FormAPI callback for the final submission.
metatag_panels_form_submit in metatag_panels/metatag_panels.module
Submission handler for Metatag panels configuration form.
metatag_views_plugin_display_extender_metatags::options_submit in metatag_views/metatag_views_plugin_display_extender_metatags.inc
Handle any special handling on the validate form.

File

./metatag.module, line 3204
Primary hook implementations for Metatag.

Code

function metatag_translations_update(array $metatags, $context) {

  // Store the context as it was originally provided.
  $original_context = $context;

  // Update the i18n string.
  if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) {
    $options = array();

    // By default disable the watchdog logging of translation messages.
    $options['watchdog'] = variable_get('metatag_i18n_enable_watchdog', FALSE);
    foreach ($metatags as $tag_name => $data) {

      // Revert the context, so that it can be changed if needed.
      $context = $original_context;
      if (!empty($data['value']) && is_string($data['value'])) {

        // Triggers hook_metatag_i18n_context_alter() - allows the i18n string
        // to be altered before being used.
        drupal_alter('metatag_i18n_context', $context, $tag_name);

        // Don't do anything if the context was erased - it's unlikely, but it
        // could happen.
        if (empty($context)) {
          continue;
        }

        // The textgroup is the first part of the string.
        i18n_string_update("metatag:{$context}:{$tag_name}", $data['value'], $options);
      }
    }
  }
}