JMSI18nRoutingBundle icon indicating copy to clipboard operation
JMSI18nRoutingBundle copied to clipboard

Make sure to add hreflang on localized pages.

Open Nyholm opened this issue 8 years ago • 10 comments

This introduces a twig function hreflang that will print <link rel="alternate" hreflang="es" href="http://es.example.com/" /> on all pages that are localized.

I do also remove calls to deprecated functions.

Nyholm avatar Aug 31 '15 14:08 Nyholm

replacing deprecated calls should be sent in a separate PR rather than being mixed with a new feature. Replacing deprecated calls probably requires less discussions than a new feature, and mixing both makes it harder to review the new feature

stof avatar Aug 31 '15 14:08 stof

Hi @Nyholm as @stof suggested would be better to only have a PR with the new feature. Can you rebase with master?

acasademont avatar Dec 02 '15 09:12 acasademont

Thank you @acasademont for taking time to review this. I have now rebased the code.

What do you think about using the twig environment instead of injecting the RequestStack?

Nyholm avatar Dec 03 '15 14:12 Nyholm

@Nyholm You need to fix the tests as well.

XWB avatar Dec 04 '15 10:12 XWB

I've updated this PR. It supports SF2.3 and the tests are fixed. @acasademont, is this ready to be merged?

Nyholm avatar Dec 05 '15 11:12 Nyholm

@Nyholm Have you also checked the i18n_locales routing option? Imagine the following setup:

jms_i18n_routing:
    locales: [nl, en, fr]
not_french:
    path: /not-french
    options: { i18n_locales: [nl, en] }

This should ignore the fr locale and only generate <link rel="alternate" hreflang="nl" href="http://nl.example.com/" /> and ```.

XWB avatar Dec 07 '15 12:12 XWB

You also need to add twig to composer.json.

XWB avatar Dec 07 '15 12:12 XWB

Thank you @XWB for your feedback. I had not considered the scenario where you do not use all locales.

I have rewritten the PR according to your comments.

Nyholm avatar Dec 07 '15 20:12 Nyholm

Hi @Nyholm @stof @XWB, how can we use this function? I see nothing in the doc... Also, is there a possibility to get all locale used in the config? SO we can use this in a controller to create a language switcher for instance, without having to duplicate all language entries...

picks44 avatar Jan 17 '17 11:01 picks44

Up ?

picks44 avatar Apr 12 '17 13:04 picks44