openstreetmap-website icon indicating copy to clipboard operation
openstreetmap-website copied to clipboard

Remove outdated pt translation

Open gravitystorm opened this issue 3 years ago • 5 comments

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:

So perhaps a better solution is to change the translatewiki export to:

  1. stop the translatewiki export from remapping pt to pt-PT,
  2. allow it to overwrite our old pt.yml,
  3. and then finally remove the pt-PT.yml file instead.

Any thoughts?

gravitystorm avatar Aug 31 '22 16:08 gravitystorm

I would go for a different file matching.

  1. find exact match (request locale) == (file name locale) "pt-br" => "pt-br.yml"
  2. search first match for (request locale).split('-')[0] == (file name locale) "pt-br" => "pt.yml" (if no pt-br.yml exists)
  3. search first match for (request locale).split('-')[0] == (file name locale).split('-')[0] "pt-foo" => "pt-pt.yml" (if no pt.yml exists)

HolgerJeromin avatar Sep 01 '22 06:09 HolgerJeromin

We already have a matching algorithm thanks, and it's much more sophisticated than that!

tomhughes avatar Sep 01 '22 07:09 tomhughes

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.

tomhughes avatar Sep 01 '22 07:09 tomhughes

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.

vgeorge avatar Sep 01 '22 09:09 vgeorge

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 }-->

tomhughes avatar Sep 01 '22 10:09 tomhughes

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.

gravitystorm avatar Apr 26 '23 09:04 gravitystorm

@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

gravitystorm avatar May 24 '23 13:05 gravitystorm

@translatewiki @Nikerabbit Please see the above comment, and please let me know if there's anything I can do to help with this. Thanks!

gravitystorm avatar Jun 12 '23 12:06 gravitystorm

Thanks @Abijeet for making the change for us!

gravitystorm avatar Jul 05 '23 11:07 gravitystorm