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

alan d.’s picture

Possibly. 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.

castawaybcn’s picture

Thanks 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.

alan d.’s picture

Status: Active » Needs review

Was 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

castawaybcn’s picture

Status: Needs review » Needs work

Updated 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.

alan d.’s picture

Status: Needs work » Fixed

I 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 :)

castawaybcn’s picture

Status: Fixed » Active

Sorry, no luck here. String still not showing as translatable.
Is there any information I can send you to help with this?

Thanks a lot.

alan d.’s picture

Status: Active » Postponed (maintainer needs more info)

The 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?

castawaybcn’s picture

field_projecte_imatges_enriquit|Descripció llarga de la imatge
What do you mean by "translation files"?
String overrides does not detect it either, do you think it could be the "ó" character?

alan d.’s picture

The 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

castawaybcn’s picture

Fear 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 imatge

Will this affect existing content if I change the extended field definition?

Thanks a lot for your work on this.

alan d.’s picture

NO

Leave the key as is, and define this new one for the translation only

alan d.’s picture

IE: To test, use the keys I provided in the string overrides

castawaybcn’s picture

I must be doing something wrong. I tried adding a new field with:

!ife:field_projecte_imatges_enriquit_tra|Some text to be translated
which gave me the error message:

"The specified key contains one or more illegal characters. Spaces or any other special characters except an underscore (_) are not allowed. The first letter can not be a number."

Then I tried with
!ife:field_projecte_imatges_enriquit_tra
And the error was:

"Each option must be a key / value pair seperated by a pipe (|)."
alan d.’s picture

Leave 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".

castawaybcn’s picture

I have worked previously with pot files, but never needed to add any string. Will give it a try though.

alan d.’s picture

There 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 "Шаблон"
========================================

castawaybcn’s picture

Thanks 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 option
key_for_second_option|Text for the second option
... and so on

Then I found somewhere that you actually have to use php instead:

return array(
  'key_for_first_option' => t('Text for the first option'),
  'key_for_second_option' => t('Text for the second option')
);

And then they show up as translatable strings. Do you think this could be a similar situation but with labels instead of values?

castawaybcn’s picture

Your 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.

alan d.’s picture

Status: Postponed (maintainer needs more info) » Fixed

No worries!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.