-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
com_fields: allowing custom field Label to be translated by a string #12656
Conversation
works as described. |
maybe, but more complex. Note : for this PR, maybe we should check the $label before using JText::_(), i.e. make sure its formatted correctly with a regex. |
isn't there a JField attribute to allow translations? i think i saw that somewhwere |
yes, but this would mean adding these in the custom field in a way or another as a choice by the user. i.e new columns i guess in the table joomla-cms/libraries/joomla/form/field.php Line 102 in 490674a
|
Where else do you need it? |
Tested further When adding the strings in en-GB.override.ini both in frontend and backend, I do get the forms translated
To solve the double translation for $key = 'JGLOBAL_FIELDS'; I guess some more owrk has to be done lines 385-410 of Therefore concerning that aspect, this PR is fine for articles as it adds the translated label in the article info. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656. |
As almost all code is getting the fields trough this function you can add the JText call of the label somewhere here https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_fields/helpers/fields.php#L102. Then you have it translated everywhere and not only during the output. |
@laoneo |
Yeps, but when you use the fields directly (they are attached to the item/article as a new variable fields) on a template override, then the label is not translated. Do we want that? If yes, then all is ok here. |
I have tested this item ✅ successfully on 4820b33 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656. |
not sure what you mean. i would need a concrete example i can reproduce easily (code included) |
In the file components/com_content/views/article/tmpl/default.php you can do |
let's get this PR merged. |
I have tested this item ✅ successfully on 4820b33 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656. |
RTC. Thanks for testing. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656. |
This patch allows the custom field label to be translated with a new string.
To test, enter a constant compatible in the Label field when you create your custom field.
Note: YES, NO, TRUE, FALSE are reserved words in INI format. ; Double quotes in the values have to be formatted as "_QQ_"
For example: JM_MYFIELD
Then add an override for the language in the Language Manager->Overrides
JM_MYFIELD="A nice demo field"
Display the field