Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correction to the language code for Português, Italian and German #903

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 12, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 12, 2023

Thanks for the pull request, @heldersepu! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Oct 12, 2023
@heldersepu
Copy link
Contributor Author

@openedx/cla-problems I completed the Contributor License Agreement form (twice) it said I should expect to see an email from DocuSign with 1 business day, but no email from DocuSign

@mphilbrick211
Copy link

@openedx/cla-problems I completed the Contributor License Agreement form (twice) it said I should expect to see an email from DocuSign with 1 business day, but no email from DocuSign

Hi @heldersepu! I will look into this for you.

@heldersepu
Copy link
Contributor Author

Hi @heldersepu! I will look into this for you.

Thanks @mphilbrick211 I received the email from DocuSing, I signed it and now waiting for the requirement to clear

image

@mphilbrick211
Copy link

Hi @heldersepu! My colleague sent you the CLA this afternoon for your review / signature. Could you please confirm if you received it?

@mphilbrick211
Copy link

Hi @heldersepu! I will look into this for you.

Thanks @mphilbrick211 I received the email from DocuSing, I signed it and now waiting for the requirement to clear

image

Great! Once you rebase it should turn green. It can take 24 hours to go through. If you're still having any issues, please let me know!

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (f098fe1) 46.44% compared to head (960f902) 46.51%.
Report is 9 commits behind head on master.

❗ Current head 960f902 differs from pull request most recent head 5151b13. Consider uploading reports for the commit 5151b13 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #903      +/-   ##
==========================================
+ Coverage   46.44%   46.51%   +0.06%     
==========================================
  Files         116      117       +1     
  Lines        2405     2408       +3     
  Branches      640      640              
==========================================
+ Hits         1117     1120       +3     
  Misses       1214     1214              
  Partials       74       74              
Files Coverage Δ
src/account-settings/site-language/constants.js 100.00% <ø> (ø)

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Oct 17, 2023
@e0d
Copy link

e0d commented Oct 17, 2023

Hi, we need to have a valid Contributor License Agreement (CLA) in place for all contributions. See the welcome message above for the details about how to enroll. The process is different depending upon whether you are making this contribution as an individual or on behalf of your employer.

@heldersepu
Copy link
Contributor Author

Hi, we need to have a valid Contributor License Agreement (CLA) in place for all contributions. See the welcome message above for the details about how to enroll. The process is different depending upon whether you are making this contribution as an individual or on behalf of your employer.

Hello @e0d I believe that requirement has been satisfied:
image

@e0d
Copy link

e0d commented Oct 18, 2023

Looks good

@heldersepu
Copy link
Contributor Author

Looks good

@e0d ... I still see the review is required

image

@e0d
Copy link

e0d commented Oct 19, 2023

I've updated the status to ensure that the reviewing team sees this is ready.

@e0d
Copy link

e0d commented Oct 19, 2023

@OmarIthawi would you be able to review this PR?

Copy link
Member

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @heldersepu for spotting the bug.

I've checked the list of supported languages and it aligns with this pull request.

However, looking at the French Candian locale which I'm assuming is correct, I see the codes need to be all lower case.

{
code: 'fr-ca',
name: 'French (CA)',
released: true,
},

Please update it as suggested and it should be good to go.

Thanks @e0d for the ping :)

src/account-settings/site-language/constants.js Outdated Show resolved Hide resolved
src/account-settings/site-language/constants.js Outdated Show resolved Hide resolved
src/account-settings/site-language/constants.js Outdated Show resolved Hide resolved
@heldersepu
Copy link
Contributor Author

@OmarIthawi thanks for the review... I just tested and it looks like the codes are case insensitive, but I like your suggestion to keep them all the same (lowercase)
I merged your suggestions ... and now the build is failing something about lint:
https://github.com/openedx/frontend-app-account/actions/runs/6576412813/job/17865793511?pr=903

@OmarIthawi
Copy link
Member

@OmarIthawi thanks for the review... I just tested and it looks like the codes are case insensitive, but I like your suggestion to keep them all the same (lowercase) I merged your suggestions ... and now the build is failing something about lint: https://github.com/openedx/frontend-app-account/actions/runs/6576412813/job/17865793511?pr=903

Great @heldersepu! The tests are failing due to commit messages. Please squash them and it should be ready to merge.

fix: Correction to the language code for Português, Italian and German

lowercase code for DE

lowercase code for IT

Co-Authored-By: Omar Al-Ithawi <[email protected]>
@heldersepu
Copy link
Contributor Author

@OmarIthawi I squashed the commits... I think it now requires an approval

@OmarIthawi
Copy link
Member

I can't approve though. But @mphilbrick211 should be able to. Would you mind helping?

@brian-smith-tcril
Copy link
Contributor

brian-smith-tcril commented Oct 19, 2023

I remember having conversations in the Translations working group about use of specific (de-DE) vs generic (de) language codes before. In the new (post OEP-58) system, we have a de.json file, but no it.json or pt.json.

I know we had issues with browser language not being supported when using the specific codes (for example, someone in Austria with a browser reporting de-AT would get de, but not de-DE).

My concern is that this PR would break the intended behavior (allowing fallbacks to the generic language code when the country code doesn't match).

@heldersepu
Copy link
Contributor Author

heldersepu commented Oct 19, 2023

I know we had issues with browser language not being supported when using the specific codes (for example, someone in Austria with a browser reporting de-AT would get de, but not de-DE).

@brian-smith-tcril the counter example to what you describe is spanish:

  {
    code: 'es-419',
    name: 'Español (Latinoamérica)',
    released: true,
  }

there is no code: 'es' in the constants or in the language files

In my tests the language is only shown correctly when the user selects it in the account preferences
image


an alternative ...
instead of updating the language code in the account-settings/site-language/constants.js
we could rename the language files to have the root/generic language on those that we have only one

@OmarIthawi
Copy link
Member

OmarIthawi commented Oct 19, 2023

I remember having conversations in the Translations working group about use of specific (de-DE) vs generic (de) language codes before. In the new (post OEP-58) system, we have a de.json file, but no it.json or pt.json.

I know we had issues with browser language not being supported when using the specific codes (for example, someone in Austria with a browser reporting de-AT would get de, but not de-DE).

My concern is that this PR would break the intended behavior (allowing fallbacks to the generic language code when the country code doesn't match).

@brian-smith-tcril I presumed that we maintain a canonical list of the languages in the following list of supported languages.

It be wrong, if that table is incorrect then we should fix it and probably move it into docs.openedx.org so also it's publicly accessible.

For the fallback mechanism, I'm afraid I don't have a good answer on that!

https://github.com/openedx/openedx-translations/blob/main/translations/frontend-app-account/src/i18n/messages/de.json

I've added this language and later removed it in Transifex after finding out that it's not what Translators would use.

The Transifex bot don't delete stale resoruces, so we should probably do that ourselves.

Anyway, this isn't to say which one is right. I don't know to be honest.

@heldersepu
Copy link
Contributor Author

I was doing some digging to my proposed alternative...

The only language( in the src/i18n/messages) with a true multi country code translation is french
image

the files de.json, it.json and pt.json are all in english, no translation there

@heldersepu
Copy link
Contributor Author

@brian-smith-tcril you make the claim:

PR would break the intended behavior (fallbacks to the generic language code when the country code doesn't match)

I do not see in the code where the const siteLanguageList is used in "browser language" I see it only on <EditableSelectField name="siteLanguage"
https://github.com/openedx/frontend-app-account/blob/open-release/palm.master/src/account-settings/AccountSettingsPage.jsx#L744

@brian-smith-tcril maybe I'm missing something... Where in the code is the siteLanguageList used for that behavior?

@brian-smith-tcril
Copy link
Contributor

@heldersepu you touched on my concern when you mentioned

the files de.json, it.json and pt.json are all in english, no translation there

I see the problem this PR is addressing (the siteLanguageList languages don't match the translation files) as having a few possible solutions:

  1. Update the siteLanguageList to use the .json files as they exist now
  2. Update the language codes so the translations live in .json files that match what's in siteLanguageList
  3. Some combination of both (keep some with country codes but switch some to not use country codes)

I want to make sure that we don't want to address this via 2 or 3 before merging 1.

@heldersepu
Copy link
Contributor Author

heldersepu commented Oct 19, 2023

Sorry @brian-smith-tcril I really don't understand what you mean in 2

  1. Update the siteLanguageList ...
  2. Update the language codes ...

The language codes are in the siteLanguageList, I think both of those options are the same


I tested changing the language in my browser to see what will be the impact for a new user
The registration page seem to have the correct language ...

French (Swiz)



French (Canadian)


Spanish (Argentinian)



I tested a few other languages (clearing cache in between) and same pattern authn/register shows correct language, but the /accounts page always shows content in english until we select and save a language in the Site Preferences.

As far as I can see the const siteLanguageList is used only on <EditableSelectField name="siteLanguage"
...and the registration form code is not part of this repo (frontend-app-account)

@heldersepu
Copy link
Contributor Author

heldersepu commented Oct 19, 2023

@brian-smith-tcril I was doing some debugging to see what happens the first time a user with a valid language like fr goes into the account page, I set a breakpoint at function getLocale this is called a few times when the page is loading

First time we can see no cookie (as expected) and it gets the lang from navigator.language correctly

But on following calls we do have a cookie and it has been set to en ?!?!

Now I see your point ... let's see if I can untangle this

@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 20, 2023
@brian-smith-tcril
Copy link
Contributor

Sorry @brian-smith-tcril I really don't understand what you mean in 2

  1. Update the siteLanguageList ...
  2. Update the language codes ...

The language codes are in the siteLanguageList, I think both of those options are the same

I'm sorry I wasn't more clear in my previous message. To clarify what I meant I'll use German as an example.

For 1 (update the siteLanguageList) this would just mean doing what this PR does. The siteLanguageList would have de-de instead of de.

For 2 (update the language codes) this would mean ensuring all the proper German translations live in de.json. This way the de that currently exists in siteLanguageList would be accurate.

However, after bringing this up in the #wg-translations channel on Slack, it seems that option 2 is not straightforward.

I believe I also see why you're getting back en as the cookie. This is happening in findSupportedLocale

findSupportedLocale examples

Logic for fr:

This shows the issue with using fr, as we only have fr_CA

if (messages[locale] !== undefined) {
  return locale;
}

we don't have messages for fr, so we continue on to

if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {
  return getPrimaryLanguageSubtag(locale);
}

the primary subtag of fr is still fr, so we still don't have messages. we continue on to

return 'en';

Logic for de_AT:

This also demonstrates the issue with using de_DE instead of de. If someone had their browser set to de_AT, we would see:

if (messages[locale] !== undefined) {
  return locale;
}

we don't have messages for de_AT, so we continue on to

if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {
  return getPrimaryLanguageSubtag(locale);
}

the primary subtag of de_AT is de, so we still don't have messages. we continue on to

return 'en';

Logic for de_AT (if we switched to using de instead of de_DE)

If, however, we used de instead of de_DE, we would see:

if (messages[locale] !== undefined) {
  return locale;
}

we don't have messages for de_AT, so we continue on to

if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {
  return getPrimaryLanguageSubtag(locale);
}

the primary subtag of de_AT is de. We have messages! We return de!

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I believe the best solution to this would be to use generic language codes in transifex instead of country specific ones, this PR addresses the immediate issue effectively.

This brings the language codes in the dropdown in line with the language codes in the supported languages table, and will address the worst of the issues.

Without this change it would be impossible for someone to use the dropdown to override undesired browser behavior.

Before this PR

  • User has browser set to de_AT, sees English because we don't have de_AT or de translations.
  • User tries to change language using dropdown, selects German (de), sees English because we don't have de translations.

After this PR

  • User has browser set to de_AT, sees English because we don't have de_AT or de translations.
  • User tries to change language using dropdown, selects German (de_DE), sees German because we have de_DE (German - Germany) translations.

@heldersepu
Copy link
Contributor Author

@brian-smith-tcril I see all the checks are green thank you!
but I do not have a button to merge, likely because that is an action reserved for approved reviews


... about the fallback mechanism (or generic language) looks like the spanish (es_419.json) was coded to be the fallback in the registration page:
Screenshot from 2023-10-21 20-17-52

We should probably do that for all that do not have a proper translation, that can be a next PR I could work on, I will raise it up in the wider Open edX Transifex Working Group as suggested by @OmarIthawi

@heldersepu
Copy link
Contributor Author

heldersepu commented Oct 22, 2023

@OmarIthawi I do not have access to the slack Open edX Transifex Working Group if you can invite me I can run point on that, if not just raise the questions yourself see what they have to say ...

things that need answers :

  • Delete stale resources, such as it.json and de.json
  • Languages not in the list of supported languages.
  • Is it OK to set language as fallback (like spanish in registration page) for languages that we have only one translation

@OmarIthawi
Copy link
Member

OmarIthawi commented Oct 23, 2023

@OmarIthawi I do not have access to the slack Open edX Transifex Working Group if you can invite me I can run point on that, if not just raise the questions yourself see what they have to say ...

@heldersepu get a invite via this link: https://openedx.org/slack

things that need answers :

  • Delete stale resources, such as it.json and de.json
  • Languages not in the list of supported languages.
  • Is it OK to set language as fallback (like spanish in registration page) for languages that we have only one translation

I can't answer those questions here, let's discuss them with the group.

@brian-smith-tcril brian-smith-tcril removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 23, 2023
@brian-smith-tcril brian-smith-tcril merged commit 5f49bed into openedx:master Oct 23, 2023
7 checks passed
@openedx-webhooks
Copy link

@heldersepu 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants