Multilingual site - i18n+i18nviews+Metatag+metatag_views. Language as suffix(site.com/en).

Internationalization: i18n.module
------------------------------------------------------------------------------
All default configurations may be translated using the Internationalization
(i18n) module. The custom strings that are assigned to e.g. the "Global: Front
page" configuration will show up in the Translate Interface admin page
(admin/config/regional/translate/translate) and may be customized per language.
---------------------------------------------------------------------------------
This work only for default configuration from Metatag group, but for tags in custom views I can't translate meta tags through translate interface.

Also I can't add translation through path tab - multiligual path's not supported :(.

How to resolve this problems?

Comments

DamienMcKenna’s picture

Title:Meta tags attached to custom views aren't translated, i18n» i18n support for Metatag submodules (Views, Contrib, Panels)
Issue tags:+D7 stable release blocker

Clarifying the title. This needs to be fixed for the final 1.0 release.

yang_yi_cn’s picture

strings in Metatag: Context are also not translatable.

DamienMcKenna’s picture

Title:i18n support for Metatag submodules (Views, Contrib, Panels)» i18n support for Metatag submodules (Views, Context, Panels)

Doh, wrote the wrong word.

yang_yi_cn’s picture

StatusFileSize
new1.98 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch metatag-1986032-4.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

created a patch for the metatag_context module (note that I made the patch on metatag module level).

This patch adds the i18n_string_update() part in add/edit admin forms of the Metatag Context module to allow translations, and pulls the translated value when display.

yang_yi_cn’s picture

StatusFileSize
new4.09 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch metatag-1986032-5.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

after some thoughts I think it's better to have the "context" part in the i18n text string name to avoid namespace conflicts with other metatag modules.

<?php
$name
= 'metatag:context:' . $context->name . ':' . $key;
?>

Patch re-rolled.

yang_yi_cn’s picture

StatusFileSize
new2.01 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch metatag-1986032-6.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

sorry, the previous patch included some unnecessary stuff related to entity_translation.

Use this one instead.

jorgemaestre’s picture

#6 Thanks yang_yi_cn, patch is working fine for me.

DamienMcKenna’s picture

Status:Active» Needs review

Status:Needs review» Needs work

The last submitted patch, metatag-1986032-6.patch, failed testing.

moonray’s picture

This patch only fixes Metatag: Context, and not Metatag: Panels or Metatag: Views yet.
It's a good start, but if you're trying out the patch, it's something to be aware of.

DamienMcKenna’s picture

DamienMcKenna’s picture

Component:Code» Multilingual/intl
N20’s picture

Patch in #6 failed for me. I think it is important to have Metatag play nice together with transleted contexts. At the moment i can not translate the Metatags for any View.

vflirt’s picture

Hi,
I have similar issue but i needed panels. As metatag panels module is almost ready to implement the translation I added jus a few more lines to get the strings to appear in the translation interface :

changed metatag_panels_form_submit as :

function metatag_panels_form_submit($form, $form_state) {
  $conf = array(
    'enabled' => $form_state['values']['metatags_enabled'],
    'metatags' => $form_state['values']['metatags'],
  );

  $form_state['handler']->conf['metatag_panels'] = $conf;

  if ($conf['enabled']) {
    $handler = $form_state['handler'];
    $instance = 'panels:' . $handler->task . ':' . $handler->subtask . ':' . $handler->name;
    foreach ($conf['metatags'] as $field => $item) {
      $name = "metatag:" . $instance . ":" . $field;
      i18n_string_update($name, $item['value']);
    }
  }
}

and then in metatag_panels_ctools_render_alter i had to change
$instance = 'panels:' . $handler->name;
to
$instance = 'panels:' . $handler->task . ':' . $handler->subtask . ':' . $handler->name;
as handler->task and handler->subtask give a bit more information where that text come from in the translation inteface.

handler->name is unique so even if stick to default of $instance = 'panels:' . $handler->name; it will be cool .

This has its issues as deleting page/variant will not remove the strings , can't refresh the strings from the administration and so on .
Maybe we could implement something as i18n_panels module does (with the panels uuid patch and ctools-uuis_for_exported_object patch) though they rely on uuid as key but as said the $handler->name is unique and adding task and subtask provide enough meaningful information so when translation the text to have proper information where this text is actually used.

Kind Regards,
Dobromir

stijndmd’s picture

StatusFileSize
new698 bytes

Considering Metatag Views:
Since the only one of the defaults here that isn't translatable is the description, here is kind of an unclean quick fix to make your view description translatable.
I know it's far from ideal, this fix, but if you're also in a hurry and need this now...

Tharna’s picture

StatusFileSize
new1.03 KB

Made this into a patch with a small change of requiring this patch to fix some notices.

Placinta’s picture

Issue summary:View changes
StatusFileSize
new1.39 KB

Attaching patch with changes proposed in #14, for Panels i18n.

Placinta’s picture

StatusFileSize
new2.82 KB

Attaching modified patch for panels i18n, that:
1) Checks for existence of i18n_string before trying to update the translation strings.
2) Removes the updated strings if the display / handler / variant is removed.

Placinta’s picture

StatusFileSize
new2.83 KB

Hiding old patches.
Attaching new patch that uses function_exists to check for i18n_string, to be more in correspondence with the code used throughout the module.

DamienMcKenna’s picture

pingwin4eg’s picture

#6 patch for metatag_context works good with metatag 7.x-1.0-beta9.

izus’s picture

Version:7.x-1.0-beta7» 7.x-1.0-beta9
Category:Bug report» Feature request
Status:Needs work» Needs review
StatusFileSize
new2.42 KB
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es).
[ View ]

Hi,
for some reason (files headers?), i couldn't apply #19
so i did it manually. and it worked fine for me, i can now have access to strings for translation in the metatag text group
here is the new generated patch file
Thanks

Thytane’s picture

Hello,

I tried the patch for metatag_panels on #22.
Patch OK. No errors when patching.

Just a little trouble if we use i18n feature for panels in a install profile. It's OK to have trads for metatags on panels but if the website is installed by a profile, there is one more action to do.

Translate backoffice said that it doesn't know the metatags strings unless you validate a second time your page_manager configuration. After that it's OK, the string is known and the traduction passed.

Thytane’s picture

Status:Needs review» Needs work
Thytane’s picture

A last thing, this patch (#22) is only for metatag_panels. It would be so great if it's possible to have a similar feature for metatag_views.
The 2 demands are really closed.

Thanks

izus’s picture

Status:Needs work» Needs review
StatusFileSize
new4.99 KB
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es).
[ View ]

hi,
following patch takes into account both panels and views.
did you try to refresh strings admin/config/regional/translate/i18n_string beofre testing ?
thx

Nick Robillard’s picture

Confirmed that patch in #6 works for Context translations

izus’s picture

StatusFileSize
new7.16 KB
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es).
[ View ]

Ok
here is a patch for panels views and context.
its just a merge of #6 and #26
Thanks

izus’s picture

Version:7.x-1.0-beta9» 7.x-1.x-dev
le72’s picture

What about taxonomy?

izus’s picture

StatusFileSize
new7.22 KB
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es).
[ View ]

hi,
i had an error with #28 for panel :
"Invalid argument supplied for foreach() metatag_panels.module:188"
following patch corrects it

maijs’s picture

StatusFileSize
new7.72 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch metatag-panels-views-context-i18n-1986032_32.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

I just filed a bug report regarding the fact that Metatag Views module does not allow user to set per-display Metatag settings (see #2289139 - Metatag settings cannot be set for each views display separately). A patch in #31 translates Metatag views settings in the same manner, saving a translation per view, ignoring a display name (translation context is view:[view-name]:[metatag-field]).

On the assumption that #2289139 is committed and that Metatag settings can be set per display, I'm attaching a patch that takes a patch from #31 and adds support for default and overridden Metatag option states. That is, if Metatag option is default (applies to all displays), translation context includes only view name (view:[view-name]:[metatag-field]). If Metatag option is overridden (applies only to one display), then translation context also includes display name (view:[view-name]:[display-name]:[metatag-field]).

DamienMcKenna’s picture

Removing this from the 1.0 blocker release, we'll get back to it after the rest of the module is stable. That said, the patch looks good and I appreciate all of the work being put into it, I just want to wait 'til the rest of the module is more stable.

marcusx’s picture

Tested this without any side effects. Works great.

jlmainguy’s picture

Hi everyone, I have applied the latest patch and I'm still getting a "Cannot refresh strings for Metatag" message when trying to refresh the strings. I see the translatable text from my Frontpage Global description meta tag, but nothing from my contexts tags (paths). Is anyone else still experiencing this issue?

sylus’s picture

StatusFileSize
new8.2 KB
PASSED: [[SimpleTest]]: [MySQL] 101 pass(es).
[ View ]

The latest patch wasn't applying for me on latest dev post v1.4 so attaching updated patch with slightly modified logic to metatag_views as $saved_metatags variable was removed in dev.

DamienMcKenna’s picture

m33_nft’s picture

litle fix for patch #36

foreach ($context->reactions['metatag_context_reaction']['metatags']['und'] as $field => $item) {
$name = "metatag:context:" . $context->name . ":" . $field;
i18n_string_update($name, $item['value']);
}

DamienMcKenna’s picture

StatusFileSize
new8.05 KB
PASSED: [[SimpleTest]]: [MySQL] 101 pass(es).
[ View ]

Rerolled, with the fix from #38 included.

JulienThomas’s picture

StatusFileSize
new3.14 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch metatag-n1986032-40.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Thanks for this patch.

However, I faced the same issue as #1781232 and thus site went simply down for non-English pages that were having overridden metatags.

As a safety measure, it may be better to encapsulate call to i18n_string_translate() (as suggested in #1781232)

I attached such a patch

Status:Needs review» Needs work

The last submitted patch, 40: metatag-n1986032-40.patch, failed testing.

oskylark’s picture

Patch #39 - I've only tested for metatag_views but perhaps related to the #38 fix, I need to use $metatags[LANGUAGE_NONE] for the final i18n_string_update loop in function options_submit in metatag_views_plugin_display_extender_metatags.inc i.e.

        foreach ($metatags[LANGUAGE_NONE] as $field => $item) {
          $name = "metatag:" . $instance . ":" . $field;
          i18n_string_update($name, $item['value']);
        }

Making this change the saved metatag strings appear in Translate interface as required.

The last submitted patch, 32: metatag-panels-views-context-i18n-1986032_32.patch, failed testing.

robinudev’s picture

Any progress on this issue?

rv0’s picture

Status:Needs work» Needs review
StatusFileSize
new3.37 KB
PASSED: [[SimpleTest]]: [MySQL] 101 pass(es).
[ View ]

Working re-roll of the metatag_views patch:

DamienMcKenna’s picture

@rv0: Thanks for the patch.

Could someone please give the patch in #47 a test run to see how well it works? Is there anything that we could add to README.txt to help explain how the functionality works?

rv0’s picture

Just some extra info:
the strings are entered into the i18n system when the metatag part in a view is submitted.
afterwards they are available for translation.

Sadly there is no automated mechanism in this patch to enter all existing views metatags in the i18n system. It would be possible to write though, but for the 6 views pages where I needed it it wasn't worth the effort.

So the functionality could use improving, but it doesn't really have to be a blocker for this patch (might as well be handled in a follow up)

DamienMcKenna’s picture

StatusFileSize
new8.02 KB
FAILED: [[SimpleTest]]: [MySQL] 90 pass(es), 11 fail(s), and 0 exception(s).
[ View ]

I've rolled in yang_yi_cn's patch from #6 into rv0's patch from #47, refactored it a bit so that there were two new functions to handle translations, and added similar support for Metatag:Panels. Please help test this. Thanks!

Status:Needs review» Needs work

The last submitted patch, 50: metatag-n1986032-50.patch, failed testing.

DamienMcKenna’s picture

Status:Needs work» Needs review
StatusFileSize
new10.34 KB
PASSED: [[SimpleTest]]: [MySQL] 101 pass(es).
[ View ]

Lets see if the tests pass now.