liberapay.com icon indicating copy to clipboard operation
liberapay.com copied to clipboard

Language variants

Open Changaco opened this issue 6 years ago • 8 comments

Our current i18n infrastructure only supports "top-level" languages, it would be great if it also supported "variants" like Brazilian Portuguese, without adding thousands of duplicate lines in the i18n/ directory.

This issue can be split into multiple steps that don't have to be implemented all at once:

  • [x] start using geographic locales to get country-specific formatting of variables (dates, numbers, etc.)
  • [ ] add a locale cookie to allow users to override their browsers' Accept-Language headers, but make sure the cookie is ignored when there is a language subdomain (e.g. fr.liberapay.com should always be in French)
  • [ ] allow users to choose the “European English” locale (en_150)
  • [ ] allow translations to vary by country

Changaco avatar Apr 16 '18 09:04 Changaco

Is it hard to change the current code to support variants?

Xinayder avatar Apr 16 '18 11:04 Xinayder

Apache redirections will be needed to redirect the currently translated pt.liberapay.com to pt_PT.liberapay.com, the same with Spanish and other translated languages. I'm worried that the URLs look weird.

jorgesumle avatar Apr 17 '18 16:04 jorgesumle

@RockyTV It's hard to do it without getting thousands of duplicate lines.

@jorgesumle We won't redirect anything, and we probably shouldn't create subdomains like pt-br or br.pt.

Changaco avatar Apr 17 '18 17:04 Changaco

Why not use ISO 3166-1 alpha-2 country codes for subdomains? It would allow a wider approach for languages.

Xinayder avatar Apr 17 '18 21:04 Xinayder

The website's content varies by language, not by country.

Changaco avatar Apr 18 '18 07:04 Changaco

Okay, I don't know how it works at the moment, but couldn't you just use the Accept-Language HTTP header and set a cookie that defines which language you'd like to use? And if you want to change your language, it will just fetch the value from the cookie, allowing the user to explicitly define which language they want to browse the site in.

EDIT: it would also get rid of the necessity of subdomains for i18n.

Xinayder avatar Apr 18 '18 23:04 Xinayder

We already use the Accept-Language header.

The subdomains provide public URLs for each version of a page, which allows linking to a specific version and enables proper indexing by search engines.

This issue is not about cookies or subdomains, it's about sharing translations between language variants. The file format we currently use to store translations doesn't support that.

Changaco avatar Apr 19 '18 07:04 Changaco

It could be done by having an extra fallback locale. So pt_BZ > pt_PT > en_US

comradekingu avatar Apr 21 '18 13:04 comradekingu