New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMP: invalid xml:lang content #632

Open
einsweniger opened this Issue Jun 21, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@einsweniger

einsweniger commented Jun 21, 2017

tl;dr: Chooser outputs XMP containing xml:lang='en_US' which is wrong.
xml:lang='en-US' is correct.

Reproduce

(Have a browser request the page with accept-language:en-US,en;q=0.8 or similar) and GET: https://creativecommons.org/choose/metadata.xmp?field_commercial=y&field_derivatives=y&field_worktitle=ISSUE&field_attribute_to_name=-1&field_attribute_to_url=https://creativecommons.org/choose/

or with curl:
curl 'https://creativecommons.org/choose/metadata.xmp?field_commercial=y&field_derivatives=y&field_worktitle=ISSUE&field_attribute_to_name=-1&field_attribute_to_url=https://creativecommons.org/choose/' -H 'accept-language: en-US,en;q=0.8' 'https://creativecommons.org/choose/'

Enter RDF-parts (everything from <rdf:RDF to </rdf:RDF>) into W3C validator to receive:
Error: {W115} Primary subtag must be between 1 and 8 alpha characters: en_US[Line = 13, Column = 39]

Fix

I guess the problem is in https://github.com/creativecommons/creativecommons.org/blob/master/python_env/src/cc.engine/cc/engine/util.py#L542
as gettext might expect a language id format other than BCP47

Quick and Easy fix

add:
target_lang.replace('_','-') after this line https://github.com/creativecommons/creativecommons.org/blob/master/python_env/src/cc.engine/cc/engine/chooser/views.py#L575

Template says to include @robmyers and @little-wow ?

@robmyers robmyers self-assigned this Jun 22, 2017

@robmyers

This comment has been minimized.

Show comment
Hide comment
@robmyers

robmyers Jun 22, 2017

Member

Thank you for reporting this.

You are correct that we are using the gettext locale identifier rather than BCP 47:

https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names

I'm actually looking at some locale-related issues in the code tomorrow, so I will try your suggested fix then.

Thanks again!

Member

robmyers commented Jun 22, 2017

Thank you for reporting this.

You are correct that we are using the gettext locale identifier rather than BCP 47:

https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names

I'm actually looking at some locale-related issues in the code tomorrow, so I will try your suggested fix then.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment