Currently, field group labels and descriptions are translated using t(). Please read
- #1157426: Field system uses t() incorrectly and inconsistently
- http://groups.drupal.org/node/149984
Why this is not the way to go. For fields this has been changed in D7.2, meaning that I had to redo all translations of field labels and descriptions, but that's the way it is.
For field groups a similar solution should be used:
- Do not use t()
- Leave localization up to i18n, in this case I think that i18n_field should also be used for field groups. This probably means work for both modules, work that should be coordinated.
Don't wait to long with this, the more users this module gets, the more difficult it will be. If you are absolutely not into i18n/l10n stuff, I might be able to do some of the work.
Comments
Comment #1
Stalski commentedField groups are not fields and I am not so sure i18n maintainers would be willing to add such functionality.
Can you explain what you have in mind and even more, it would be very appreaciated if you could give it a go. I am always happy to review patches. I can assure you that your work would be valuable.
Comment #2
fietserwinIMO, for site builders fields and field groups are very closely related. Personally I think field groups should be part of the core fields module (probably a sub-module as most field types are now).
But back to the problem at hand: it is not only related to fields, but to all user (including site-builders) provided input. (So I will have to have a look at the module I currently maintain as well.) http://groups.drupal.org/node/149984 further explains the problem and hints at i18n_string as a more common solution for contributed modules.
I will open an issue in the i18n queue and ask how they think about this?
Comment #3
Stalski commentedYes, I think that the best clausible step to take
Comment #4
fietserwinCross link to issue in i18n: #1175802: Support for field groups?
Comment #5
Stalski commentedComment #6
trigdog commentedWas there ever a decision made for this? Is there going to be multilingual support for the field group title / description any time soon? Thanks!
Comment #7
q2_faith commented+1
Comment #8
nils.destoop commentedI think i18n_fieldgroup should be created for this. Anyone up for this?
Comment #9
trigdog commented@Jose Reyero just created a module for contributed add-ons for i18n. This might be a good spot for the i18n field group code.
Comment #10
emorency commentedAny progress on this issue ?
For those waiting for this issue to be resolved, here is a patch that applies the same strategy as for the title field (have a check_plain(t(....)) )...
Comment #11
fietserwinIt is better to use filter_xss() instead of check_plain() as titles typically may contain spans or other inline elements.
Comment #12
emorency commentedThanks for the advice. Here is the patch with call to filter_xss() instead of check_plain()
Comment #13
emorency commentedSorry... Duplicate post with #12...
Comment #14
a6hiji7 commented@emorency
Thanks for your patch, it works and solves the problem for me. Whereas I appreciate the great work being done by contributed module developers, the pace of fixing issues like this is agonizingly slow. This means a great deal of frustrations for people who are developing websites using the framework and the modules.
Comment #15
carajito commentedCan I used this patch for 7.x-2.x-dev????
Comment #16
emorency commentedDescription of htabs were not translated by the previous patch. This patch includes #12 changes.
Comment #17
adelka commentedI've used the patch but I still can't translate labels. How can I translate it?
Comment #18
Stalski commentedIt would be nice if people tested Webflo's field_group sandbox project.
I don't know much about internationalisation but I guess this patch would interfere with the new approach.
Comment #19
nils.destoop commentedIdd, once the i18n_field_group is finished. No t() strings are needed anymore. So none of the patches will be committed to field_group.
Comment #20
adelka commentedWell, but what is the estimated time of beta version release?
Comment #21
nils.destoop commentedNo idea yet, maybe it's best to ask on the issue queue there. http://drupal.org/sandbox/webflo/1413404
Comment #22
Stalski commentedI'll close this in favor of http://drupal.org/sandbox/webflo/1413404
Comment #23
donquixote commentedI still think it would be preferable to implement this directly in field_group.
Comment #24
samirmtl commentedHi
Sorry but we are not sure that SandBox experimental project, (https://drupal.org/comment/6550078#comment-6550078) , can be used when build profiles distribution by drupal, so here a pach that we can use to patch 1.3 version of filed_group module
the #16 (https://drupal.org/comment/6335106#comment-6335106) pach is no more applicable, when Drupal build our Mica-distribution there are some errors
Comment #25
samirmtl commentedComment #26
samirmtl commentedHi
Sorry but we are not sure that SandBox experimental project, (https://drupal.org/comment/6550078#comment-6550078) , can be used when build profiles distribution by drupal, so here a pach that we can use to patch 1.3 version of filed_group module
the #16 (https://drupal.org/comment/6335106#comment-6335106) pach is no more applicable, when Drupal build our Mica-distribution there are some errors
(Sorry for the last comment the pach is a wrong one (Please use this one )
Comment #27
pfrenssenThis was closed as fixed two years ago by referring to a sandbox. In the meanwhile the sandbox has been abandoned. Reopening so this can be fixed properly in this module.
Comment #28
pfrenssenNone of the patches here take the correct approach. We should not use
t()to translate labels. We should usei18n_stringinstead.Comment #29
guybrush threepwood commentedI am interested in working on this. Can you show me a current module that uses i18n to translate it?
Thanks.
Comment #30
fietserwin- webform localization: https://www.drupal.org/project/webform_localization
- i18n views: https://www.drupal.org/project/i18nviews
- i18n documentation: https://www.drupal.org/node/133977, more specifically: https://www.drupal.org/node/1114010
Comment #31
guybrush threepwood commentedJust as an update, I have finished this. I just need to put it into a patch at this point. I should be able to submit it in a couple of days.
Comment #32
guybrush threepwood commentedSo in order to make the translations, I need to have a few modules enabled like i18n. Should we put this requirement in the .info file, or should I just make the check and only translate it if these modules are enabled, allowing the module to not require the i18n modules if translation is not desired?
Comment #33
guybrush threepwood commentedIn order for the module to work, you need to go to "Configuration > Regional and Language >Translate Interface >Strings" and click the refresh strings button after selecting "Field Group Localization"
Additionally these modules are required to make it work: (It will run without them, it just won't translate if you don't have them)
i18n
locale
block
translation
variable
i18n_translation
i18n_block
i18n_string
Comment #34
guybrush threepwood commentedComment #40
guybrush threepwood commentedComment #41
guybrush threepwood commentedComment #42
guybrush threepwood commentedComment #43
nils.destoop commentedThx for picking this up :)
Seems like a lot of dependencies.
Why is block and i18n_block required? fieldgroup has nothing to do with blocks, and you only use i18n_string in code. People can use field_group without having blocks module installed, so this is a blocker.
It's also not needed to check for variable and translation. Because i18n has it as dependency. If i18n is installed, the 2 will always be installed. Same goes for i18n, i18n_string has i18n as dependency. So the checks of i18n, translation, variable can be removed.
I also don't see the dependency to i18n_translation.
Also remove this check:
As you are already doing it before you call the function.
Comment #44
nils.destoop commentedComment #45
guybrush threepwood commentedYeah, that makes sense. I will make that change.
Comment #46
guybrush threepwood commentedI believe this patch has the changes mentioned in #44.
Comment #47
guybrush threepwood commentedI think it has some white space issues. Let me fix that.
Comment #48
guybrush threepwood commentedHere is the updated patch.
Comment #49
guybrush threepwood commentedComment #50
guybrush threepwood commentedNow that I look at it, I think that i18n_string requires the locale module, so I took the check for the locale module out in this patch
Comment #51
guybrush threepwood commentedI have spotted a few minor errors that I will fix.
Comment #52
guybrush threepwood commentedI tested the module on non-vanilla website and found a few issues to fix. Here is the latest patch.
Comment #53
guybrush threepwood commentedComment #54
guybrush threepwood commentedI fixed an error that I found. I believe this is the last one I can find without any other help in reviewing the patch.
Comment #55
guybrush threepwood commentedI think I found another error, I will post the fix soon.
Comment #56
guybrush threepwood commentedComment #57
guybrush threepwood commentedI believe this is the patch that needs to be reviewed.
Comment #58
guybrush threepwood commentedComment #59
guybrush threepwood commentedComment #60
guybrush threepwood commentedComment #61
guybrush threepwood commentedAnyone willing to test this?
Comment #62
giupenni commentedNot work.
I found the string in admin/config/regional/translate/translate, added the translation but in the node is displayed only the Original text.
I've just flush the cache ad run cron
I've applied only #57 patch
Comment #63
guybrush threepwood commentedOk. Thanks for testing. I will look into this soon to get some clarification. Are you running a vanilla Drupal 7 site?
Comment #64
guybrush threepwood commentedStill looking at it.
Comment #65
guybrush threepwood commentedOk. I think I found the problem. When you use git to get the dev version of the field group module apply the patch inside of the field group directory. That should solve the problem. I may have created the patch incorrectly or something. But this should make it work. @giupenni can you check it out? Just applying patch #57 should work.
Comment #66
giupenni commented7.x-1.x branch or 7.x-2.x branch?
Comment #67
giupenni commentedOk, I think I found the problem.
If I translate an existing field group label the patch not work as I've reported in #62.
If I create a new field group label it works as expected.
There is a workaround to avoid to delete and create again the field group?
Comment #68
guybrush threepwood commentedThis patch is for the 7.x-1.x branch. After applying the patch, Did you try going to Admin->configuration-> regional and language -> translate interface and then click on the strings tab and then try clicking the Field Group Localization check box and then clicking the refresh strings button?
Comment #69
guybrush threepwood commentedAlso, if you put the same label for the manage display label and the manage fields label, they will need to be translated separately. If you put the field group label in both, did you translate both of these?
Comment #70
giupenni commentedYes, I tried this but not works with the fields group that I have added before the patch. I found the string in admin/config/regional/translate/translate, added the translation but in the node is displayed only the Original text.
If I create a new field group it works.
Yes, I can translate both separately.
Comment #71
guybrush threepwood commentedAlright. I will make a fresh copy of Drupal 7, add the dev version of Field Group, create a new Field Group, then patch the field group module with #57 patch, and then try to translate. I will try to do this soon, and then fix it. Am I understanding you correctly that these are the steps to find the error you found?
Comment #72
giupenni commentedYes, correctly.
Just one clarification: I don't know if this is can be relevant but I've created the field with stable version (7.x-1.5) and after I upgraded to dev+patch version.
I too will try to do tests, both starting from the stable version than dev.
Comment #73
guybrush threepwood commentedI had a few emergencies pop up so I haven't been able to look at it for a couple of days, but I will get back to this soon.
Comment #74
giupenni commentedWell. I have made a fresh copy of D7, added the stable version of Field Group, created a new Field Group with label, then patched the field group module with #57 patch and dev version. It works!
At this point I don't know because in my installation, that I reported in #67, not works.
Anyway I think this patch works and fixes the issue.
Comment #75
giupenni commentedAny update?
Comment #76
idebr commentedWhen comparing this patch with the sandbox that contains the i18n integration for Field group (https://www.drupal.org/sandbox/webflo/1413404), the sandbox has a more clean approach and actually uses the hooks that are in the field_group.api.php. I would suggest starting a new patch starting with the sandbox, fix the @todo's mentioned in the code and add that as a submodule for Field group.
Comment #77
giupenni commented+1 #76
I've already used this sandbox module in another project and works without problem.
Comment #78
guybrush threepwood commented@idebr. Thanks for the feedback. I'll create a new patch with that, unless someone has already done it.
Comment #79
mittinatten commentedHave the same problem as #70
Comment #80
quantos commentedHi guys. I'm struggling to get access to any translatable Field Group labels following the above steps and elsewhere. Are Field Group labels now translatable? Any module/approach would do for us but following all steps I've seen we can not find and module/submodule going by the name 'field group translate' and can't not find any of our existing or new test Field Group labels at admin/config/regional/translate/translate every filter/search there comes up blank for any existing field group labels or new ones added just to test this out.
NB we're following the steps from https://www.drupal.org/project/field_group/issues/1751002 which includes:
+++
Steps:
Install i18n, field_group field translation. Enable a second language (e.g. FR),
- enable multi.language for the article content type, add a field set and give it a label and description
- go to admin/config/regional/translate/translate and search for the label and description entered above.
- add an example text field within the field set and translate the field
- the field label/description can be translated fine
- whereas the fieldset label can be found and translated, but not the description cannot
+++
From these steps we cannot find the first-mentioned "field_group field translation" (submodule I presume?) but have followed all other steps.
#68 on this thread states "click on the strings tab and then try clicking the Field Group Localization check box and then clicking the refresh strings button?" but of course there's no sign of that checkbox that or any similar name. Hence the opening query; "Are Field Group labels now translatable?"
What have we missed? The location of any "field_group field translation" submodule or something?
Thanks in advance for any pointers/help with this.
Q.
Comment #81
quantos commentedIgnore that guys. I have just found it. I thought I'd tested all possibilities but for the last round of testing I was only updating the Display pages Field Groups. When I added the Field Group label to the Manage Fields tab instead, they came through straight away. I haven't tested further on but presume all translation functions are now built directly into the Field Group module directly (are therefor there is no submodule to be found)! Thanks to anyone/everyone who has worked on this in the past meantime.
Q.
Comment #82
chris matthews commentedComment #83
nils.destoop commented