Skip to content

fix(settings): show active forced locale or language instead of 'No locale set' (#41543) #53364

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arc64
Copy link

@arc64 arc64 commented Jun 6, 2025

Summary

When a forced locale or language is set by the administrator, this PR ensures the appropriate message is displayed instead of the misleading 'No locale set'.

  1. Updated getLanguageMap() and getLocaleMap() in PersonalInfo.php to pass through validated forced settings. If settings are malformed, no forced value is passed (falls back to default).
  2. Modified LanguageSection.vue and LocaleSection.vue to correctly handle display conditions:
  • If forcedLocale or forcedLanguage exists, show 'Locale is forced to {locale} by the administrator' or 'Language is forced to {language} by the administrator'.
  • If no forced value and no user settings are present, it falls back to 'No locale set' / 'No language set'.
  1. Added tests for both Vue components to ensure correct behaviour

Before

Issue #41543 - Screenshot

After

Forced locale / language:

Forced

User-set locale / language:

Set by user

TODO

  • Check if PHP unit tests are required for getLanguageMap() and getLocaleMap(). I have not written tests yet, as running them in the current docker dev container was not successful (due to missing full test environment / FS setup). Feedback welcome.
  • Check that the messaging in the views is inline with Nextcloud expectations - 'Locale is forced to {locale} by the administrator' and 'Language is forced to {language} by the administrator'.

Notes

When the locale is set (either by the user or forced by an administrator), it is displayed in English, regardless of the current interface language. This matches existing behaviour in user settings.

Checklist

@arc64 arc64 requested review from a team as code owners June 6, 2025 08:34
@arc64 arc64 requested review from susnux, nfebe, skjnldsv and yemkareems and removed request for a team June 6, 2025 08:34
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Nice, thank you for the pull request! Added some comments :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice that there is a test but for this its probably also good to add a cypress e2e test.

Copy link
Author

Choose a reason for hiding this comment

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

I haven't committed the cypress tests yet, as I'm struggling to get them running with my current setup (https://github.com/juliusknorr/nextcloud-docker-dev).

@susnux susnux added this to the Nextcloud 32 milestone Jun 6, 2025
@arc64 arc64 force-pushed the fix/41543-forced-locale-language-display branch from a852913 to 767d1d3 Compare June 10, 2025 13:16
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@arc64 arc64 force-pushed the fix/41543-forced-locale-language-display branch from 767d1d3 to 015d87a Compare June 24, 2025 09:34
- Clarified the naming in the validate functions
- Removed unnecessary mocks, and added stubs in tests.
- Testing for existence of element with data-test attributes, and without relying on translated text.
- Removed overly complex component mocking

Signed-off-by: Annabel Church <[email protected]>
@arc64 arc64 force-pushed the fix/41543-forced-locale-language-display branch from 015d87a to 262c9f8 Compare June 24, 2025 09:39
@arc64 arc64 requested a review from susnux June 30, 2025 11:53
@arc64
Copy link
Author

arc64 commented Jun 30, 2025

I forgot to re-request a review, done now, @susnux thank you for your comments and labour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show active locale or language when either are forced rather than misleading No locale set
2 participants