You are here

function hook_metatag_i18n_context_alter in Metatag 7

Allow the context string passed to i18n_string to be changed before use.

If the string is set to an empty value it will cause this meta tag to not be translated.

Parameters

string $context: The context string being passed into i18n_string. Will usually be in the format "[category]:[path-identifier]", e.g. "[node:123]", "[page:contact]", etc.

string $tag_name: The name of the meta tag being translated.

3 invocations of hook_metatag_i18n_context_alter()
metatag_translate_metatag in ./metatag.module
Translates the metatag if i18n_string integration is enabled.
metatag_translations_delete in ./metatag.module
Remove the translated definitions of meta tags.
metatag_translations_update in ./metatag.module
Update the translated definitions of meta tags.

File

./metatag.api.php, line 472
API documentation for the Metatag module.

Code

function hook_metatag_i18n_context_alter(&$context, $tag_name) {

  // Don't bother translating the canonical URL.
  if ($tag_name == 'canonical') {
    $context = '';
  }
}