Closed wesleybl closed 1 year ago
If I press f5 several times, I can see that the interface is initially loaded in English and then converted to Portuguese.
When I use pt-BR
instead of pt-br
, it works as expected.
pt-br
should it work too? If not, the documentation needs to be updated:
(hearsay) there's all kind of shenanigans when the frontend language code doesn't match the backend language codes. I think we need a better "language negociation" mechanism.
@sneridagh In this commit: https://github.com/plone/volto/commit/c579124a00d6da0b32e3d26bc291e595a3e4ee85, you save the I18N_LANGUAGE
cookie in the lang_COUNTRY
format (e.g. pt_BR). But everywhere you read a language to get the translation file, you use the normalizeLanguageName
method, to convert it to pt_BR
format. So I ask, couldn't the cookie be saved in pt-br
format? I think part of this problem is caused by the cookie in the pt_BR
format, since the content of Plone has the language format as pt-br
.
I would have to revisit it to remember the whole problem. I think that it was that internally gettext uses _ and Plone - so yiu have to "normalize" them at some point. We decided to normalize it to Plone way. If the issue are duplicated requests somewhere, we need to address it but we'll have to deal with this situation anyways I guess.
@sneridagh it looks like react-intl
uses the pt-BR
format. See:https://stackoverflow.com/questions/48988389/what-format-of-locale-does-react-intl-use
It even seems that the pt_BR
format is not even supported by react-intl
. I saw this comment:
https://github.com/plone/volto/blob/848cbe155f97662d510613a4e9f0c6e2ba482ee1/src/helpers/Utils/Utils.js#L194-L196
So I propose to write cookie I18N_LANGUAGE
in pt-BR
format instead of pt_BR
and convert the pt-br
Plone content to pt-BR
I renamed the folder https://github.com/plone/volto/tree/master/locales/pt_BR to pt-BR
and yarn i18n
worked.
Can it be like this?
One thing I noticed is that Plone Classic writes the I18N_LANGUAGE
cookie in the pt_BR
format. Would it be a problem for Volto to record in a different format? Is that why Volto used the pt_BR
format until now?
@sneridagh This (and #4644) are blocking the usage of Volto with Brazilian sites right now.
@wesleybl @ericof With #4741 I am seeing 2 requests for /@actions
even in an English site, so I'm not sure this is entirely related to language codes.
The I18N_LANGUAGE cookie comes from the Plone backend language negotiation in plone.i18n; it needs to remain in the format expected there.
Fixed in https://github.com/plone/volto/pull/4741. (There are still 2 requests for @actions
, but that is unrelated to the language. See https://github.com/plone/volto/issues/2781 and https://github.com/plone/volto/issues/4263)
Describe the bug
When we configure Voto to use Brazilian Portuguese as the default language, Plone api requests are made twice. If you check the browser development tool, after pressing F5, you will see two requests to the following URLs:
To Reproduce Steps to reproduce the behavior:
follow the prompts questions, provide myvoltoproject as project name then, when it finishes:
cd myvoltoproject
Expected behavior I expect requests to be made only once. When the site is in English, these duplicate requests do not occur.
Software (please complete the following information):