Hi!

How could I use the metatag and i18n to set them for seo?
I set the the description, abstract, keywords in "admin/config/search/metatags/config/global".
I transleted these strings in "admin/config/regional/translate/translate". But these still are the original strings. It doesn't use the translated strings. (In the html source are the original metatag strings.)
(cache was cleared)

What could I set? Or do I use it badly?

Comments

mparker17’s picture

Title: metatag i18n settings » Translated global metatag defaults do not display (show originals instead)
Component: Miscellaneous » Multilingual/intl
Issue summary: View changes

I've been experiencing the same problem.

Here's how to re-create on a fresh site:

  1. drush dl drupal-7.25
  2. drush si
  3. drush dl ctools-7.x-1.3 i18n-7.x-1.10 metatag-7.x-1.0-beta7 token-7.x-1.5 variable-7.x-2.3
  4. drush en ctools i18n i18n_string metatag token variable
  5. Log in as the super-admin.
  6. Go to admin/config/regional/language, click "Add language", choose "French (Français)", click "Add language" button.
  7. Go to admin/config/regional/language/edit/en, set "Path prefix language code" to en and click "Save language" button.
  8. Go to admin/config/regional/language/configure. Enable the "URL" detection method, and click "Save settings".
  9. Go to en/admin/config/search/metatags, click "Override" next to "Global". In "Description", enter Lorem ipsum in English.. Click "Save".
  10. Go to en/admin/config/regional/translate/translate. Set "Limit search to" to Metatag and click "Filter" button. Click "Edit" next to the row with the context "global:description". Set the "French" translation to Ipsum Lorem en Français.. Click "Save translations".
  11. Go to en/admin/structure/block. Move the "Language switcher (User interface text)" block into the "Header" region (or similar). Click "Save blocks".
  12. Flush all caches.
  13. Go to en/node (i.e.: the front page of the site in English). View the source. Note there is a meta tag <meta name="description" content="Lorem ipsum in English." />.
  14. In the language switcher, click "Français". Flush all caches and reload the page. View the source.

    Expected behaviour

    There is a meta tag <meta name="description" content="Ipsum lorem en Français." />.

    Actual behaviour

    There is a meta tag <meta name="description" content="Lorem ipsum in English." />.

mparker17’s picture

Okay, I stepped through metatag_translate() in a debugger to see what was happening.

The problem is the "context" (i.e.: global:description). When I load the frontpage of my site, instead of using the global:description settings, it uses the global:frontpage:description settings instead (in the code, metatag: is prepended to the above context names).

If I delete the "global" setting and put it in the "frontpage" one instead, it works. Put another way, if I change step 9 in my previous comment to say...

  • Go to en/admin/config/search/metatags, click "Override" next to "Global: Front page". In "Description", enter Lorem ipsum in English.. Click "Save".

... then I would have got my expected functionality (but only for the front page). I'd probably have to do something similar (i.e.: set the translatable string on the 'leaves' of the metatag defaults tree) to get it to work on other pages.

In the case of the description, that's not too bad, since most pages have their own descriptions anyway, but for things like twitter:site (which is what I'm trying to do on my project, since my client has separate English and French twitter accounts), it's a lot of work.


I guess that means this is working as designed, but I'd argue that what it does is not very intuitive and could probably be improved.

Thoughts / suggestions / comments?

Cyclodex’s picture

Version: 7.x-1.0-beta7 » 7.x-1.4
Assigned: Unassigned » Cyclodex

I had the same issues and was now looking heavily into this.
There are some tricky parts, for example it also did not work if the string of an element (abstract or description etc.) is the same for frontpage and global. There it doesn't look up correctly the global context.

I am not the metatag or string translation expert, but I could solve the issue which was because of inheritance and context look ups which did not work out correctly.

I will post a patch soon, so you can test if it would work out for you as well.

Just wanted to take over the task for the moment.

damienmckenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Assigned: Cyclodex » Unassigned
Category: Support request » Bug report

@Cyclodex: Were you able to work out a fix?

damienmckenna’s picture

damienmckenna’s picture

I'm moving back the fixes to this issue, will deal with the submodules separately.

damienmckenna’s picture

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new2.16 KB

Does this work better?

damienmckenna’s picture

I'm working on a changenotice for this: https://www.drupal.org/node/2550865

damienmckenna’s picture

StatusFileSize
new2.49 KB

A small tidying of the code, plus extra comments.

damienmckenna’s picture

I've also added a change notice for the argument changes to metatag_translate(): https://www.drupal.org/node/2550883

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed ece299c on 7.x-1.x
    Issue #2113501 by DamienMcKenna: Shortened i18n translation context to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kumkum29’s picture

Hello,

i get the same problem on my site: in the front page only the default metas are displayed.

Step 1:
In en(or fr)/admin/config/search/metatags, I have clicked on "Override" next to "Global: Front page" (or Global). In "Description", i have entered Metas EN and click "Save".
Step 2:
I opens the two home page (EN & FR).
Step 3:
In the translation page, I create the translated string for the description : Metas EN > Metas FR
Step 4:
In the home page of french language I get the description in english...

I have uninstalled and reinstalled the module and I get the same problem.

Here is the print_r(metatag_metatags_view('global:frontpage', array())); in the french home page:

[description] => Array
        (
            [#attached] => Array
                (
                    [drupal_add_html_head] => Array
                        (
                            [0] => Array
                                (
                                    [0] => Array
                                        (
                                            [#theme] => metatag
                                            [#tag] => meta
                                            [#id] => metatag_description_0
                                            [#name] => description
                                            [#value] => Metas EN ///Bad string
                                            [#weight] => 2
                                        )

                                    [1] => metatag_description_0
                                )

                        )

                )

        )

Have you any idea for resolve this problem? Thanks.

P.S.: if I uses a string and a token in the description, the token is translated in the good language. The string isn't translated.

Edit: I have found a solution for the front page with metatag context, but it's not so easy and no option for the global metatags.

damienmckenna’s picture

@kumkum29: Please open a new issue and I'll be able to help you.

Xrobak’s picture

metatag 7.x-1.17 still not fixed... could you update the stable version? thx

damienmckenna’s picture

@Xrobak: Please open a new issue so I can help you work out the exact source of the problem. Thanks.

Xrobak’s picture

@DamienMcKenna, done #2831198