Closed (fixed)
Project:
ImageField Extended
Version:
6.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Aug 2011 at 11:16 UTC
Updated:
21 Sep 2011 at 23:31 UTC
I've just created and used a custom imagefield field form as instructed:
my_custom_image_field|Human readable description
Everything works flawlessly, but "Human readable description" does not allow for translation, and since it is used for the label in the form, it shows untranslated to the end user. Would this be very difficult to achieve?
Thank you for such a useful module.
Comments
Comment #1
alan d. commentedPossibly. It would probably be done via something like this in the module code:
t('!ife:FIELD_CODE', array('!ife:FIELD_CODE' => check_plain(FIELD_TITLE))
This solution is not great, but it is sorta of like a poor-mans cron to i18n in Drupal.
Comment #2
castawaybcn commentedThanks for your answer. I would really like to give this a try, but I just have no idea where to put that code in the module's file.
Comment #3
alan d. commentedWas it just the form? If so, I've committed a version to dev that should come out in the next 24 hours sometime which needs some testing. If it resolves the issues, mark this thread as "fixed".
Cheers
Comment #4
castawaybcn commentedUpdated to latest dev (30/08 I believe), cleared caches and refreshed strings, but the issue persists.
I am not using the label in the node's display, just for editing, so I just have noticed this issue in the edit form.
Comment #5
alan d. commentedI done the labels on the page, not the other way around. Committed the fix for both.
!ife:KEY for textfields
!ife:workflow_KEY for checkboxes
!ife-help:KEY for description
Reopen is you have any issues :)
Comment #6
castawaybcn commentedSorry, no luck here. String still not showing as translatable.
Is there any information I can send you to help with this?
Thanks a lot.
Comment #7
alan d. commentedThe dev version has the code, and this was working on my local install:
I used strings overrides module to test and these showed through without any issues. What are your keys and the translation files?
Comment #8
castawaybcn commentedfield_projecte_imatges_enriquit|Descripció llarga de la imatgeWhat do you mean by "translation files"?
String overrides does not detect it either, do you think it could be the "ó" character?
Comment #9
alan d. commentedThe keys for translation would be something like this:
!ife:field_projecte_imatges_enriquit
!ife-help:field_projecte_imatges_enriquit
Or if a checkbox, this
!ife:workflow_field_projecte_imatges_enriquit
By "field_", I'm hoping that you are not using the image field name?? The key is the key used to define the additional field in the ImageField settings page
Comment #10
castawaybcn commentedFear not, I know better than using the image field name as a key ;) If I understand correctly then I should define my fields like this, right?
!ife:field_projecte_imatges_enriquit|Descripció llarga de la imatgeWill this affect existing content if I change the extended field definition?
Thanks a lot for your work on this.
Comment #11
alan d. commentedNO
Leave the key as is, and define this new one for the translation only
Comment #12
alan d. commentedIE: To test, use the keys I provided in the string overrides
Comment #13
castawaybcn commentedI must be doing something wrong. I tried adding a new field with:
!ife:field_projecte_imatges_enriquit_tra|Some text to be translatedwhich gave me the error message:
Then I tried with
!ife:field_projecte_imatges_enriquit_traAnd the error was:
Comment #14
alan d. commentedLeave your existing keys as they are and translate these in the pot files using the special forms of the keys that I supplied.
I do not personally know how to set up locale specific translations, but say you change Hello to Hola, you use Hello as the key, and Hola as the spanish translation. Read though the doco on how to do this, I do not know how to use the pot files.
So for the standard default language, leave the imagefield key / values as they are, say "myfield|My english name for this field". Then define the new translation keys using "!ife:myfield" and the translation, say "The spanish name for my field".
Comment #15
castawaybcn commentedI have worked previously with pot files, but never needed to add any string. Will give it a try though.
Comment #16
alan d. commentedThere would be a translation for each language:
ImageField Settings
========================================
Textfields
-------------
mykey|Pattern
========================================
And standard translation AND ImageField translations for the word Pattern.
German de.po
========================================
msgid "Pattern"
msgstr "Muster"
msgid "!ife:mykey"
msgstr "Muster"
========================================
French fr.po
========================================
msgid "Pattern"
msgstr "Motif"
msgid "!ife:mykey"
msgstr "Motif"
========================================
Russion ru.po
========================================
msgid "Pattern"
msgstr "Шаблон"
msgid "!ife:mykey"
msgstr "Шаблон"
========================================
Comment #17
castawaybcn commentedThanks for this, will try adding the po files and see if it works.
I remembered something else though, it may not be relevant, but just in case here it is.
If you define the list of possible values for a cck select list the default way (key|label) they are not translatable:
key_for_first_option|Text for the first optionkey_for_second_option|Text for the second option... and so on
Then I found somewhere that you actually have to use php instead:
And then they show up as translatable strings. Do you think this could be a similar situation but with labels instead of values?
Comment #18
castawaybcn commentedYour solution worked beautifully, and it's easier than expected: you only need to import a single po file with the string into a language other than the default, then the string shows up for translation in the rest.
Thanks a lot for this.
Comment #19
alan d. commentedNo worries!