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
Comment #2
vuilComment #3
vuilReplace
gsw-bernewithgsw.Comment #4
vuilI add an old (7.x-dev) issue for the same as related:
#600438: Add Swiss German language to l.d.o
Comment #5
vuilAnd, I think this is another (7.x-dev) related issue:
#2471947: Rename incorrect language title "Swiss German" to "Bernese German"
Comment #6
vuilComment #7
vuilUpdate the issue summary.
Comment #8
vuilComment #9
vuilAnother (different) solution - modified the output only:
from
hreflang="gsw-berne"tohreflang="gsw".Comment #10
cilefen commentedComment #11
vuilUpdate the summary only.
Comment #12
vuilUpdate the issue summary.
Comment #13
vuilUpdate both patches #3 and #9.
For
Drupal 8.9.xversion.Comment #14
vuilComment #15
angel.hNo need for the first check as you assign 'gsw' as a value next.
Comment #16
vuil@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.
Comment #17
rgpublicDon'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
Comment #18
vuilI re-worked the "output modified only" patch for
Drupal 8.7.xbranch.Comment #19
vuilI re-worked the "output modified only" patch for
Drupal 8.9.xbranch.I already hided the duplicated (old version) patches.
Comment #22
sir_squall commentedAnd 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.
Comment #24
madhu_h commentedVerified 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
Comment #28
nikhil_110 commentedAttached patch against Drupal 10.1.x
Comment #29
vuilComment #30
vuilComment #31
smustgrave commentedThe 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.