openstreetmap-website
openstreetmap-website copied to clipboard
Remove outdated pt translation
As found while working on #3653 we have a stray translation file pt.yml that hasn't been updated in around 8 years.
My first thought is to simply remove it immediately, since it's woefully outdated, and we have pt-PT and pt-BR translations that are kept up to date. But my concern is that without this file, any browser requesting "pt" will see the default English translation, since our Locale detection doesn't "fall-forwards" i.e. it doesn't choose a more specific locale if the more general locale is missing.
After removing the pt.yml file:
Locale.available.preferred(Locale.list("pt"))
=> #<struct Locale language="en", script=nil, region=nil, variant=nil, extension=nil, privateuse=nil, grandfathered=nil>
Locale.available.preferred(Locale.list("pt-PT"))
=> #<struct Locale language="pt", script=nil, region="PT", variant=nil, extension=nil, privateuse=nil, grandfathered=nil>
Would this limitation be acceptable? Does anyone know how common it is for browsers to request "pt" translations, as opposed to "pt-PT" or "pt-BR"?
An alternative would be to change one of the two pt-* translations to use the pt key, and then the regular fallbacks would cover all situations. It's worth noting here that:
- Translatewiki has
ptandpt-br - transifex for iD has
ptandpt_BR - rails-i18n also has
ptandpt-BR.
So perhaps a better solution is to change the translatewiki export to:
- stop the translatewiki export from remapping
pttopt-PT, - allow it to overwrite our old
pt.yml, - and then finally remove the
pt-PT.ymlfile instead.
Any thoughts?
I would go for a different file matching.
- find exact match
(request locale) == (file name locale)"pt-br" => "pt-br.yml" - search first match for
(request locale).split('-')[0] == (file name locale)"pt-br" => "pt.yml" (if no pt-br.yml exists) - search first match for
(request locale).split('-')[0] == (file name locale).split('-')[0]"pt-foo" => "pt-pt.yml" (if no pt.yml exists)
We already have a matching algorithm thanks, and it's much more sophisticated than that!
The actual code is https://github.com/openstreetmap/openstreetmap-website/blob/master/lib/locale.rb but trying to understand it is not for the faint hearted ;-)
It will never try and add components though - there is actually data for that in CLDR but I don't really want to get into that and it's unnecessary here.
What @gravitystorm proposes will work just fine and is what I would do - it's also equivalent to your algorithm in it's effects if I'm understanding things correctly.
In the browsers I have in my machine, Chrome, Safari and Firefox, only the first allows setting pt, pt-PT or pt-BR. As it is very popular, I think the number of users that have pt setting might not be negligible.
If an user has a pt setting I think there is a higher probability of being a Brazilian user, because of the number of internet users in Brazil (160M) and Portugal (8M). If there isn't any other information about language usage I would go with pt-BR as the fallback in the approach proposed by @gravitystorm.
I would suggest that we go with what CLDR says which I assumed would be pt-PT but actually it seems to agree with you:
<likelySubtag from="pt" to="pt_Latn_BR"/>
<!--{ Portuguese; ?; ? } => { Portuguese; Latin; Brazil }-->
Based on the previous two comments, I think we have decided to use the pt-BR translation for any plain pt requests. Is that correct? If so, we can ask translatewiki to change one line in their configuration, to export pt-br to pt.yml as per the following tables:
Current:
| Translatewiki code | current mapping TW-OSM | OSM filename | used for browsers requesting... |
|---|---|---|---|
| pt-br | pt-br: pt-BR | pt-BR.yml | pt-BR |
| pt | pt: pt-PT | pt-PT.yml | pt-PT |
| - | - | pt.yml | pt |
Proposed:
| Translatewiki code | proposed mapping TW-OSM | OSM filename | used for browsers requesting... |
|---|---|---|---|
| pt-br | pt-br: pt | pt.yml | pt-BR, pt |
| pt | pt: pt-PT | pt-PT.yml | pt-PT |
Here's the source for the translatewiki remappings, for reference.
@translatewiki can we please reconfigure the locale export configuration as follows:
diff --git a/groups/OpenStreetMap/OpenStreetMap.yaml b/groups/OpenStreetMap/OpenStreetMap.yaml
index 16f82d7f..d802105e 100644
--- a/groups/OpenStreetMap/OpenStreetMap.yaml
+++ b/groups/OpenStreetMap/OpenStreetMap.yaml
@@ -13,7 +13,7 @@ TEMPLATE:
en-gb: en-GB
es-mx: es-MX
ku-latn: ku-Latn
- pt-br: pt-BR
+ pt-br: pt
pt: pt-PT
sr-ec: sr
sr-el: sr-Latn
@translatewiki @Nikerabbit Please see the above comment, and please let me know if there's anything I can do to help with this. Thanks!
Thanks @Abijeet for making the change for us!