-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Conversation
4ba7368
to
23dc168
Compare
There was a problem hiding this 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.
23dc168
to
d2da817
Compare
d2da817
to
c8a0950
Compare
947a1aa
to
1ac3ca0
Compare
There was a problem hiding this 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 withnull
. 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.
@@ -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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that.
e1bb84e
to
45c3e8c
Compare
Closing this for now until it's ready |
This PR …
Enhancement
label
of the Panel's languages dropdown for the currently selected language