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

Language label for the language switcher dropdown #5770

Closed
wants to merge 5 commits into from

Conversation

distantnative
Copy link
Member

@distantnative distantnative commented Oct 9, 2023

This PR …

  • Support to edit in language dialog

Enhancement

  • Language: customize the label of the Panel's languages dropdown for the currently selected language

@distantnative distantnative requested review from a team October 9, 2023 18:14
@distantnative distantnative self-assigned this Oct 9, 2023
@distantnative distantnative force-pushed the v4/enhancement/language-label branch from 4ba7368 to 23dc168 Compare October 9, 2023 18:18
@afbora afbora changed the base branch from main to v4/develop October 9, 2023 18:42
@lukasbestle lukasbestle changed the title V4/enhancement/language label Language label for the language switcher dropdown Oct 9, 2023
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

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

TBH I'd keep the "translate" icon. One could still hide it via CSS if it doesn't fit.

@afbora
Copy link
Member

afbora commented Oct 10, 2023

What do you think about also new optional label field for the language dialogs? Maybe it should be sync with code field as default.

image (4)

@bastianallgeier bastianallgeier force-pushed the v4/enhancement/language-label branch from 23dc168 to d2da817 Compare October 18, 2023 09:27
@distantnative distantnative added this to the 4.1.0 milestone Oct 19, 2023
@distantnative distantnative force-pushed the v4/enhancement/language-label branch from d2da817 to c8a0950 Compare October 19, 2023 16:32
@distantnative
Copy link
Member Author

Added

Screenshot 2023-10-19 at 18 54 58

@distantnative distantnative force-pushed the v4/enhancement/language-label branch from 947a1aa to 1ac3ca0 Compare October 20, 2023 12:33
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

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

If the label is left blank, the fallback to the code does not work.

Two possible solutions I can think of:

  • Change Language::update() to replace an empty string for the label with null. This way, a dev could still manually set an empty string in the language file. But if changed via the UI, leaving the field blank will make it fall back to the code.
  • In the frontend, use a similar logic like with the code and locale fields (when changing the name or code fields, automatically update the label fields with the uppercase code). This one would probably be the most flexible as then the label could also be manually set to an empty string from the UI.

tests/Cms/Languages/LanguageTest.php Outdated Show resolved Hide resolved
@@ -59,6 +60,7 @@ public function __construct(array $props)
$this->code = trim($props['code']);
$this->default = ($props['default'] ?? false) === true;
$this->direction = ($props['direction'] ?? null) === 'rtl' ? 'rtl' : 'ltr';
$this->label = trim($props['label'] ?? Str::upper($this->code));
Copy link
Member

@afbora afbora Oct 22, 2023

Choose a reason for hiding this comment

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

This line is not working correctly. The label prop from the frontend is always sent as empty string. So if user doesn't enter label, language dropdown shows empty string.

Should be empty check for $props['label'] instead null check or label argument should be sent as null if not entered.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, also ran into that. See the possible solutions in the comment above.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I missed that.

@distantnative distantnative force-pushed the v4/enhancement/language-label branch from e1bb84e to 45c3e8c Compare November 3, 2023 19:20
@distantnative distantnative marked this pull request as draft November 4, 2023 13:12
@distantnative distantnative changed the base branch from v4/develop to develop November 28, 2023 09:19
@distantnative distantnative changed the base branch from develop-patch to develop-minor November 29, 2023 14:23
@distantnative distantnative modified the milestones: 4.1.0, 4.2.0 Jan 18, 2024
@distantnative distantnative added the needs: changes 🔁 Implement any requested changes to proceed label Jan 18, 2024
@distantnative
Copy link
Member Author

Closing this for now until it's ready

@distantnative distantnative removed this from the 4.2.0 milestone Feb 3, 2024
@distantnative distantnative deleted the v4/enhancement/language-label branch June 15, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: changes 🔁 Implement any requested changes to proceed
Development

Successfully merging this pull request may close these issues.

3 participants