? Success

User tests: Successful: Unsuccessful:

avatar infograf768
infograf768
31 Oct 2016

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

avatar infograf768 infograf768 - open - 31 Oct 2016
avatar infograf768 infograf768 - change - 31 Oct 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 Oct 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 31 Oct 2016
Category Front End Components
avatar andrepereiradasilva
andrepereiradasilva - comment - 31 Oct 2016

works as described.
But, shouldn't the same be done to other parts. e.g.: the descriptiom, hint placeholder, etc (dependng on the field)

avatar infograf768
infograf768 - comment - 31 Oct 2016

maybe, but more complex.
Little by little :)

Note : for this PR, maybe we should check the $label before using JText::_(), i.e. make sure its formatted correctly with a regex.

avatar andrepereiradasilva
andrepereiradasilva - comment - 31 Oct 2016

isn't there a JField attribute to allow translations? i think i saw that somewhwere

avatar infograf768
infograf768 - comment - 31 Oct 2016

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
https://github.com/joomla/joomla-cms/blob/490674af202168fd5bad38a44fe6a84ef7c894a2/libraries/joomla/form/field.php#L102

avatar infograf768
infograf768 - comment - 1 Nov 2016

In fact, this PR is absolutely not enough. This is only used in frontend.
We do get there by using in render.php

var_dump($field->description);
var_dump($field->params['hint']);

string 'mydescription' (length=13)

string 'ahint' (length=5)

and when editing and debugging
screen shot 2016-11-01 at 08 40 26

avatar laoneo
laoneo - comment - 1 Nov 2016

Where else do you need it?

avatar infograf768
infograf768 - comment - 1 Nov 2016

Tested further

When adding the strings in en-GB.override.ini both in frontend and backend, I do get the forms translated
JMFIELD="My field"
AHINT="Test a translation of hint"
MYDESCRIPTION="Test a translatable description"

screen shot 2016-11-01 at 04 10 19
Remark: The Fields tab is double translated
Which is not the case when I use a Field Group AND add a new string
screen shot 2016-11-01 at 04 15 41
with
CONTENT-GROUP_1="Custom fields 1"

To solve the double translation for $key = 'JGLOBAL_FIELDS'; I guess some more owrk has to be done lines 385-410 of ROOT/administrator/components/com_fields/helpers/fields.php

Therefore concerning that aspect, this PR is fine for articles as it adds the translated label in the article info.
But will we always need to display the label in some other cases (when not editing a form)? I guess it is should be possible to choose to only display the value.
In that case the label should be hidden and only the value displayed.
What do you think?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656.

avatar laoneo
laoneo - comment - 2 Nov 2016

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.

avatar infograf768
infograf768 - comment - 7 Nov 2016

@laoneo
It is by default translated in the forms. It is in the display that it is not.

avatar laoneo
laoneo - comment - 7 Nov 2016

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.

avatar Bakual Bakual - test_item - 7 Nov 2016 - Tested successfully
avatar Bakual
Bakual - comment - 7 Nov 2016

I have tested this item successfully on 4820b33

Frontend now displays the translated label.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656.

avatar infograf768
infograf768 - comment - 7 Nov 2016

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.

not sure what you mean. i would need a concrete example i can reproduce easily (code included)

avatar laoneo
laoneo - comment - 7 Nov 2016

In the file components/com_content/views/article/tmpl/default.php you can do print_r($this->item->fields);. It will print the fields. Here are the labels not translated. That was what I was talking about.

avatar infograf768
infograf768 - comment - 8 Nov 2016

print_r($this->item->fields); will just not work anyway (Gets the details of the array) and doing an echo instead of print_r will create the array to string conversion error.

let's get this PR merged.

avatar ggppdk ggppdk - test_item - 8 Nov 2016 - Tested successfully
avatar ggppdk
ggppdk - comment - 8 Nov 2016

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.

avatar infograf768 infograf768 - change - 8 Nov 2016
Status Pending Ready to Commit
avatar infograf768
infograf768 - comment - 8 Nov 2016

RTC. Thanks for testing.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12656.

avatar roland-d roland-d - change - 13 Nov 2016
Milestone Added:
avatar roland-d roland-d - close - 13 Nov 2016
avatar roland-d roland-d - merge - 13 Nov 2016
avatar roland-d roland-d - reference | 1a21f17 - 13 Nov 16
avatar roland-d roland-d - merge - 13 Nov 2016
avatar roland-d roland-d - close - 13 Nov 2016
avatar roland-d roland-d - change - 13 Nov 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-11-13 06:26:42
Closed_By roland-d
avatar joomla-cms-bot joomla-cms-bot - change - 13 Nov 2016
Category Front End Components Front End com_fields Components
avatar infograf768 infograf768 - head_ref_deleted - 13 Nov 2016

Add a Comment

Login with GitHub to post a comment