Opened on 07/09/2017 at 06:01:19 PM
Closed on 09/13/2017 at 01:30:55 PM
#5392 closed change (fixed)
Map Facebook & Crowdin locale codes
Reported by: | juliandoucette | Assignee: | juliandoucette |
---|---|---|---|
Priority: | P2 | Milestone: | |
Module: | Websites | Keywords: | |
Cc: | kvas, jsonesen, wspee, ire, saroyanm, matze, ferris, rraceanu | Blocked By: | #5402 |
Blocking: | Platform: | Unknown / Cross platform | |
Ready: | no | Confidential: | no |
Tester: | Unknown | Verified working: | no |
Review URL(s): |
Description (last modified by juliandoucette)
Background
We can use og:locale and og:locale:alternate meta fields in our web pages to specify the current page locale and available locales for each page (See example).
However, it seems the crodwin language codes are not the same format or value as facebook language codes.
What to change
Create a global function that provides og:locale codes based on website locale codes provided in settings.ini.
Use this function to set og:locales on all websites.
Attachments (0)
Change History (17)
comment:1 Changed on 07/10/2017 at 06:36:07 AM by scheer
- Cc rraceanu added; scheer removed
comment:2 Changed on 07/11/2017 at 12:26:52 AM by juliandoucette
- Blocked By 5402 added
comment:3 Changed on 07/11/2017 at 12:49:30 AM by juliandoucette
- Description modified (diff)
- Summary changed from Standardize locale codes and formats to Map Facebook & Crowdin locale codes
comment:4 Changed on 07/11/2017 at 06:51:05 AM by matze
What you call "Facebook compatible locale codes" is an actual locale or locale code, though without any .codeset or @modifier. The Open Graph protocol explicitly requires locales to be given in this notation.
Now these "crowdin language codes" are part of their API documentation. They are not the same as a locale. So, where's the connection? Why, where and when do you want to translate from a language code within a vendor's API to a locale compliant with Open Graph?
comment:5 Changed on 07/11/2017 at 10:34:06 AM by juliandoucette
What you call "Facebook compatible locale codes" is an actual locale or locale code, though without any .codeset or @modifier. The Open Graph protocol explicitly requires locales to be given in this notation.
Yes.
I called them "Facebook compatible locale codes" and not "locale codes" because there are two exceptions that Facebook makes to the ISO standard which are documented here.
Now these "crowdin language codes" are part of their API documentation. They are not the same as a locale. So, where's the connection? Why, where and when do you want to translate from a language code within a vendor's API to a locale compliant with Open Graph?
I want to write Jinja like this:
<meta property="og:locale" content="{{ locale }}"> {% for alternate_locale in locales %} {% if alternate_locale != locale %} <meta property="og:locale:alternate" content="{{ alternate_locale }}"> {% endif %} {% endfor %}
To set "Facebook compatible" og:locale and og:locale:alternate meta field values based on the locales of our web pages.
I was assuming that the locales provided to our CMS via our websites settings.ini were "Crowdin language codes" because many of them were only two chars. However, it seems there is a little bit of conversion going on under the hood here already. Nonetheless, the locale codes that are already being used in our websites' [settings.ini, paths, and Crowdin] are not the same as those supported by Facebook via Open Graph tags.
comment:6 follow-up: ↓ 7 Changed on 07/11/2017 at 02:08:56 PM by matze
Thank you for the explanation! Quick follow-up question: Can't you define a set of /locale_path/ specific variables within our CMS already? Hence perform that very mapping / computation for alternate_locale in the repository?
comment:7 in reply to: ↑ 6 Changed on 07/12/2017 at 01:02:22 PM by juliandoucette
Replying to matze:
Thank you for the explanation! Quick follow-up question: Can't you define a set of /locale_path/ specific variables within our CMS already?
I believe the locale_paths you are referring to come from language codes defined in settings.ini per repository.
Hence perform that very mapping / computation for alternate_locale in the repository?
Yes. But I'd prefer not to add this function to every website repository - hence this issue (to add such a function to CMS).
I'm guessing that it would be easiest to use facebook codes in settings.ini and simplify them for crowdin (and potentially paths/urls) in CMS. But I trust Sitescripts to come up with the most appropriate solution considering the potential side effects (changing urls, changing locale codes in crodwin)
comment:8 Changed on 07/13/2017 at 08:37:58 AM by ire
- Cc ire added; iaderinokun removed
comment:9 Changed on 07/14/2017 at 11:46:55 AM by juliandoucette
comment:10 Changed on 07/22/2017 at 06:59:23 PM by juliandoucette
- Blocking 1274 added
comment:11 Changed on 07/22/2017 at 08:32:35 PM by juliandoucette
- Component changed from Sitescripts to Websites
- Description modified (diff)
- Priority changed from Unknown to P2
Moving this to websites module based on a conversation with kvas on IRC.
Mapping (more specific) ~Facebook codes to (less specific) ~Crowdin codes can be ambiguous. We think it's better idea to implement this as a shared global in website-defaults (given that we are also prioritizing the implementation of shared globals/includes/filters/etc).
comment:12 Changed on 07/23/2017 at 11:34:34 AM by juliandoucette
- Blocking 5329 added
comment:13 Changed on 08/09/2017 at 10:44:48 PM by juliandoucette
- Blocked By 5329 added
- Blocking 5329 removed
- Priority changed from P2 to P3
- Review URL(s) modified (diff)
comment:14 Changed on 08/09/2017 at 10:51:26 PM by juliandoucette
- Blocking 1274 removed
comment:15 Changed on 09/04/2017 at 05:17:19 PM by juliandoucette
- Priority changed from P3 to P2
Bumping this up in priority because the existing implementation is fragile (because it's hard coded with no fallback for missing keys).
comment:16 Changed on 09/05/2017 at 02:47:26 PM by juliandoucette
- Owner set to juliandoucette
comment:17 Changed on 09/13/2017 at 01:30:55 PM by juliandoucette
- Blocked By 5329 removed
- Resolution set to fixed
- Status changed from new to closed
Fixed by:
- https://hg.adblockplus.org/web.adblockplus.org/rev/f5e93e848876
- https://hg.adblockplus.org/web.adblockplus.org/rev/dbc717aadeda
---
Facebook will scrape all available locales and display them according to your Facebook account locale. Unfortunately there is a bug in Facebook preview that causes all share previews to display in English. But the final share will display in the appropriate Facebook account locale.
Note: I had previously guessed that Facebook's scraper would be smart enough to guess the correct locale based on a two letter code or a code with a - instead of a _. However, I performed the test outlined in #5402 using these incorrect formats and fb_locale was not passed as a result.