Problem / Motivation

The wrong (by W3C) head hreflang="gsw-berne" HTML tag:

<link rel="alternate" hreflang="gsw-berne" href="https://www.domainXXX.com/ch/ihr-spezialist-fur-abdichtungen-und-markierungen" />

which is reported by W3C as an error (attached screenshot):

Error: Bad value gsw-berne for attribute hreflang on element link: Bad variant subtag berne.

From line 22, column 1; to line 22, column 128

<link rel="alternate" hreflang="gsw-berne" href="https://www.domainXXX.com/ch/ihr-spezialist-fur-abdichtungen-und-markierungen" />↩<link

Proposed resolution

There are two variants for the issue fix:

1. Patch the core language version #3. For new projects.

2. Modify the output only (#9). More suitable for existing (old) projects.

Both of the patches replace core language hreflang="gsw-berne" (German Swiss language) with hreflang="gsw" (W3C compliant).

Comments

vuil created an issue. See original summary.

vuil’s picture

Issue summary: View changes
vuil’s picture

Status: Active » Needs review
StatusFileSize
new2.92 KB

Replace gsw-berne with gsw.

vuil’s picture

I add an old (7.x-dev) issue for the same as related:

#600438: Add Swiss German language to l.d.o

vuil’s picture

vuil’s picture

Title: Replace 'gsw-berne' (Swiss German language) with 'gsw' (W3C compliant) only » Replace 'gsw-berne' (Swiss German language) with 'gsw' (W3C compliant)
Issue summary: View changes
vuil’s picture

Issue summary: View changes

Update the issue summary.

vuil’s picture

Issue summary: View changes
vuil’s picture

Another (different) solution - modified the output only:
from hreflang="gsw-berne" to hreflang="gsw".

cilefen’s picture

Version: 8.7.x-dev » 8.9.x-dev
Category: Support request » Bug report
vuil’s picture

Issue summary: View changes

Update the summary only.

vuil’s picture

Issue summary: View changes

Update the issue summary.

vuil’s picture

Update both patches #3 and #9.
For Drupal 8.9.x version.

vuil’s picture

Issue summary: View changes
angel.h’s picture

Status: Needs review » Needs work
+++ b/core/modules/content_translation/content_translation.module
@@ -677,10 +677,14 @@ function content_translation_page_attachments(&$page) {
+        if ($hreflang === 'gsw' || $hreflang === 'gsw-berne') {

No need for the first check as you assign 'gsw' as a value next.

vuil’s picture

@angel.h This is required to be working well with both core and new (patched) version. :) Yes, you are right. The patch requires re-work.

rgpublic’s picture

Don't want to spoil the party, but gsw (or its subvariant gsw-berne) is a swiss dialect and not the usual German used for Swiss websites. The correct language code for normal Swiss German is "de-ch". There is hardly any website in Switzerland that uses the gsw language. I don't understand why "gsw" has ever been introduced in Drupal as "Swiss German" as it is outright wrong and causes confusion. See my comments here:

https://www.drupal.org/project/localizedrupalorg/issues/1328690

vuil’s picture

I re-worked the "output modified only" patch for Drupal 8.7.x branch.

vuil’s picture

Status: Needs work » Needs review
StatusFileSize
new848 bytes

I re-worked the "output modified only" patch for Drupal 8.9.x branch.

I already hided the duplicated (old version) patches.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

sir_squall’s picture

And what about adding all the swiss language? Not only the swiss german, we are missing the french and the italianne here, and this can create multiple issue, if we want to manage the currencies per language for example.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

madhu_h’s picture

Status: Needs review » Needs work
StatusFileSize
new146.91 KB

Verified and tested the Merge request !
https://www.drupal.org/files/issues/2019-11-28/modified-output-hreflang-...


Testing Steps:
# Setup Languages and language selector on a site
# Add Swiss-german language to the site
# Visit Homepage
# Inspect Swiss-german appearing in language selector
# Verify that hreflang value is appearing as gsw instead pf gsw-berne

Test Results:
Unable to apply patch provided , it seems incompatible with Content Translation module

Note: Note that Swiss-german language is present with languages provided by Drupal but Swiss French and Swiss Italian languages are not present with languages provided by Drupal and site builder can add them as custom language specifying language code

Refer SS:

Test Status: FAIL

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nikhil_110’s picture

StatusFileSize
new806 bytes

Attached patch against Drupal 10.1.x

vuil’s picture

vuil’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update, +Needs tests

The issue summary mentions a screenshot but I don't see one, unless it's the code snippet

The proposed solution mentions 2 approaches can it be highlighted which was chosen and why.

#28 will need test coverage

Thanks.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.