Can entity translation translate alt or title fields of images? I do not want images to be translatables (all translations have common images) but only title or alt tags.

Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

calculus’s picture

Thank you plach. Is there a documentation for this?

plach’s picture

No, we need a patch committed first ;)

calculus’s picture

I'm sorry. You tagged this thread as fixed, and i thought that this functionality is available already.

plach’s picture

I marked a support request fixed: this simply means I provided a (IMO) complete answer. The issue about the feature I linked in the first reply is in 'active' status.

Status: Fixed » Closed (fixed)

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

kumkum29’s picture

Component: Code » Base system

Hello,

as Calculus, I want to translate alt and title but not translate the image. Seeing this post, I installed the "Entity Translation" module and adjust "Translatable entity types" on "file" ("Select which entities can be translat" in admin / config / regional / entity_translation). The following options are checked: "Hide language selector", "Prevent Being changed language from once the entity has-been created" in Entity Translation module / and in "Synchronize translations" tab (i18n module) i have checked my picture field.

If I insert words in the field alt, these words are synchronized with the other language.
What should be done so that I can get an alt tag for each language?

Thank you for your help.

P.S. I use ET 7.x-1.0-beta2

plach’s picture

Field synchronization is not tied to the i18n settings, if you edit the field settings for your image field you should find a "Sinchronize translations" checkbox. Unless you are using Media in which case field synchronization is not needed, since in that case "alt" and "titles" are fields that can be translated in the usual way.

calculus’s picture

I added an image field (with multiple values) to user bundle.
I enabled translation with sync option (synchronization using this, not i18n).

Then i add some images with alt tag and translate them. So far everything works fine. The images are the same for every translation (i don't have different image files per translation) and alt tags are different.

But if i erase every image, the theme function (f.e. render($user_profile['field_myimages']) in user-profile.tpl.php) still produces html code with no values!

Can anyone reproduce it or there is something am i doing wrong?

I did not try it with node bundles.

titouille’s picture

Issue summary: View changes

I'm facing the same problem as calculus.

Image field added to "article" content-type, translation enabled, synchronization enabled. Field named "field_article_images".

I create a node (english), upload an image, set alt/title values in english.
I create the translation (french). Image is already embed, set alt/title values in french.

All works good. In database, field_data_field_article_images contains 2 rows, one for english, one for french.
Now if I delete the picture from the node, only one row is deleted in database. second row already exists. I suspect that's because the "translation" state is enabled.

If a field can be "translatable", also field content must be changed independently for each language. We must edit the the node for each language. But in this particular case, field is "translatable", but already "synchronizable" on column level. The behavior is not the same as another kind of field only translatable...

If anyone has a solution it would be nice. I would like to see into entity_translation.module if I find a way to resolve it but not sure I deeply understand all implications.

titouille’s picture

Ok... with the last dev version problem is gone. Sorry for commenting here before test... And thanks for this nice module

mibfire’s picture

I set the entity translation in node type and in admin/config/regional/entity_translation for file image and enabled image translation in image field settings, but this doesnt work with latest dev(03-Apr-2015). I have two languages, english and hungarian. If i upload one image for hungarian node then it can be seen on english one too, even though there is no image for english one(I checked the hungarian and english node edit). It is strange cos syncronization isnt enabled. How should this be set? thx

hefterbrumi’s picture

Please correct me if I did not get this right:

IF I use regular image field I create a content and upload an image to the imagefield. I can translate the image's (as a file entity) alt and title field through the file browser.
Outcome: I enable field translation (synchronisation ticked, alt and title fields unticked) I have to add a translation on every language to display translated alt and title fields properly. If I dont add translation to other languages apart from the default one, the alt and title fields wont be translated.

IF I use media image field I can upload or select Images translate the alt and title fields in the file browser.
Outcome: I enable field translation (synchronisation unticked). If I add translations to every language it wont work. If I dont add any other translations it wont work.

My conclusion is that alt and title field translation is working only with regular image fields in contents where there are translations on every available languages.

Desired Functionality:
Images can be uploaded and translated separately through the file browser. If I use the image on a content that is not translated only on the default language alt and title should be translated according to the current language. (reason: A lot of multilang sites have e.g. portfolio items that shouldnt be translated, however image alt and titles should be)

Odd Functionality:
If I empty all caches, image alt and titles translated to that language which was current when I emptied the cache.

hefterbrumi’s picture

FileSize
83.61 KB
102.04 KB
99.64 KB

I discovered that this is not related to media. I learned from the database that I have to resave every node to have all the alt fields updated on the attached images. However every time I save the node (on different languages), the value of alt or title field becomes NULL on the current language (please see image attached).

All the images are taken from table field_data_field_portfolio_image. Image1 was before I resaved the node, but after saved new translations and alt tags to the file (entity). Image2 and Image3 show how alt values changes to NULL depending on which language I resaved them on.

I could reproduce this issue on simplytest.me as well.

hefterbrumi’s picture

Status: Closed (fixed) » Needs review
plach’s picture

Field synchronization is meant to be used with alt and title field properties enabled in the instance settings:

To achieve what you outlined above you need an untranslatable media image field and a translatable file entity with translatable alt and title fields. This will let you translate images only via the media popup dialog. In this case field synchronization is useless and should be disabled.

hefterbrumi’s picture

Thank you for the answer. Excuse my obscurity but the second method does not work with the current release as my previous post (#14)describes. I have my untranslatable image fields (type image, widget media browser, unlimited values), I upload an image that translated entity. Outcome: same as I described that you can see in the database.

I retested with untranslated image field: Alt fields are not translated in html and gets NULL value in database despite it was translated as an entity before (the image itself).
I retested with translated image field: Alt fields are translated, however the current language (which I save on) gets NULL value in the database.

I can reproduce this on simplytest.me.

hefterbrumi’s picture

Status: Fixed » Needs review
plach’s picture

Status: Needs review » Fixed

The answer to this support request is in my previous post. The fact that things do not work as intended means there's a bug.

I can reproduce this on simplytest.me.

Ok, then please open a new issue with the list of steps to reproduce the issue (feel free to copy them from here). Please reference it form here, see https://www.drupal.org/project/entity_translation#bugfixing for more details.

hefterbrumi’s picture

The related issues is to be solved:
Translate alt and title with file entity/media

Status: Fixed » Closed (fixed)

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