We have alt and title fields now (https://drupal.org/node/1307054)

But they are language neutral, the same text is shown on all languages.

Members fund testing for the Drupal project. Drupal Association Learn more


rob_johnston’s picture

I think this is related: #1470018: Provide Entity Translation integration. Still working through this myself.

mgifford’s picture

Ok, so that issue for Entity Translation was fixed in October, but I think this is still a problem with at least the released version of Media.

@rob_johnston did you get it working?

rob_johnston’s picture

That issue gave me some clues as to what to expect and let me try to list them here (hope I don't skip a step):

  1. I went to /admin/config/regional/entity_translation and under "Translatable entity types" I enabled "File".
  2. On the same page, for the "File" type I now have the "Image" set to default to the current language and to exclude language neutral (my preference).
  3. I then went to /admin/structure/file-types and for the "Image" type, under "Manage fields", I edited the "Alt Text" and "Title Text" and clicked "Enable translation" at the bottom.
  4. I then edited the content type and synchronized the image field across translations

So when I do that, after creating the content in English, saving, and creating the translation in French, I click the edit button for the image. I then see a new button up on the top left (easy to miss) that says "Add French translation" and a drop-down that indicated that I'm currently editing the English version. This is the clue that I got from the referenced issue. This form that pops-up is very similar to the full file edit form (e.g. if I know my file is saved as number 1234 then I could go to /file/1234/edit).

So, does this work for anybody else? Non-intuitive, I'd say, and I think that this pop-up form should be in the current language so the "Add French translation" button could disappear. It's an extra step that would be easy for a user to forget to do.

mgifford’s picture

I'm trying to replicate this, but having trouble. I've got the alt text translation enabled here:

But I'm also using the media module so that might be messing things up. When I edit an image here:

I don't see anything that allows me to edit the image.

In step 4 when I edit an image I'm not seeing anything for the translation:

Screen Shot of Media module pop-up

But ya, definitely not intuitive.

rob_johnston’s picture

It's possible that I forgot a step, but I can't think what it might be.

When you go to edit an individual file from the /admin/content/file/edit-multiple page, do you get the "Translate" link on the top-right of the screen?

It wasn't until I synchronized the image field between translations that I saw the "Add French translation" button appear on the top left of that pop-up form that you attached. If the image has a different file number in both languages then the button doesn't appear. If you were to add a line to the "entity_translation" table where entity_type=file, entity_id=34, language=fr, source=en, status=1, and translate=0, etc, would you then see the button?

supermoos’s picture

Did any of you find a way to enable alt and title translations? I have enabled the alt & title fields as translatable under the file types. And under /admin/config/regional/entity_translation, I've also tried both enabling and disabling field translation of the image field on my content type - seems to make no difference. The only thing that seems weird is that under my node content type edit form and the "Synchronize translations"-tab, no fields are available for synchronization?

davidk2’s picture

re: #3 rob_johnston - it works for me. Both fields (alt + title) are translated now, but title + alt atributes in HTML code has still only one language in all translated entities/images.

pikku-h’s picture

Im not sure if this should be separate issue, but the same thing happens without translations:

  1. Node 1 has image with title "Title 1"
  2. Create Node 2, pick (the same image as in Node 1) image from library and set image title to "Title 2"
  3. Node 1 image title is now "Title 2"
mgifford’s picture

Issue summary: View changes
Issue tags: +accessibility, +i18n
Leksat’s picture

Version: 7.x-2.0-unstable7 » 7.x-2.0-alpha4
Status: Active » Needs review
4.36 KB
PASSED: [[SimpleTest]]: [MySQL] 922 pass(es). View

Here is a patch providing basic support for entity translation. I've tested in only with media field.

The translation support works only if both parent entity and file entity are managed by entity_translation module.

The file entity translation handler in the media popup form inherits form/source language from the parent entity translation handler when it's possible.

I've made the patch on the base of 7.x-2.0-alpha4 because latest 7.x-2.x (3fc13e9) does not work for me at all.

J-Lee’s picture

Patch #10 is working for me (7.x-2.0-alpha4). Thank you Leksat!

Edit: If you use fields for alt and title text:
I noticed that the file/image default language should set to "current language" at the entity translation settings. If not, alt and title text won't shown after uploading new imagesbecause they are in a wrong language.

Sebbon’s picture

Patch works on alpha4. It does not give me a language/translation switcher button in the mediabrowser popup when editing a image in a node. However, if I switch to the other language during editing of the node (using the language switch of the node) and then open the image file media browser with the edit button I see the translatable fields for Alt and Title. Works like a charm.

Drupal 7.36
Media 7.x-2.0-alpha4+37-dev

Ahmad Abbad’s picture

Patch #10 is working for me (7.x-2.0-alpha4).

FiNeX’s picture

Im' using the latest -dev version ( 2015-Jun-30 ) and the parent entity is translated using i18n (not entity translation).

The file entity is translatable: on file/edit/ID the "translate" tab is visible and it works fine (switching the language the alt/tab attributes are correctly loaded) but the media browser popup always loads the file entity using the default language and it doesn't show the translation switcher.

idebr’s picture

Version: 7.x-2.0-alpha4 » 7.x-2.x-dev
5.19 KB
PASSED: [[SimpleTest]]: [MySQL] 1,095 pass(es). View
1.47 KB

I updated the patch with the use case from #14

hefterbrumi’s picture

I am having a problem with this. I am using media module, the language switcher is loaded correctly (3 language site). However if I empty all caches, all my images alt and title field becomes "stuck" in the language that was the current one when I emptied the cache (so If a user changes language with the language switcher alt and tilte texts stays the same).
If I resave a contect (e.g portfolio Item) the alt and title field will change and stuck in the language that was active when I resaved the content.

I dont know if this is a media or entity translation issue. I am using the latest dev releases of them.

I have to correct this:
If I empty all caches or resave the content type my alt text (and title) translations behaves abnormally. They become mixed up. If I browse an image through the file browser, click view and change the language with the language switcher it works fine, however if I do the same on any content types (or views) where the images are served through media module it will be mixed up.

mgifford’s picture

Can you tell us how to replicate it on SimplyTest.me?

Will be the best way to determine if it is an issue with your site or this patch.

hefterbrumi’s picture

I learned that this might not be a media issue but entity translation. I have posted my tests here, plese take a look:

stefan.r’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

#15 works like a charm and the code looks OK!

IMO this should be major as Alt and Title fields really ought to be translatable.

#18 seems to be referring to the issue in #16, so it should not block this patch

doitDave’s picture

@#19 +1 for the priority, subscribed. i18n should be considered #1, it is one of Drupal's best powers.

james.williams’s picture

Patch #15 only covers the case of a translatable parent entity (with translatable fields on the referenced file entity). The case of an untranslatable parent entity referencing file entity that is translatable will need resolving. But in order to to avoid holding up the work on the case that patch #15 is aiming for, it may be best to deal with that in a second issue (which would be blocked on this work until this first case is resolved).

stefan.r’s picture

Title: Media browser translatable alt and title fields » Media browser translatable alt and title fields for translatable parent entity
hefterbrumi’s picture

I think my issue is related to this as well. It makes media useless for me to translate alt and title fileds of translatable image entities. Although Now I think it is likely a file entity problem.

Image Alt and Title displayed in the wrong language IF field format is not "rendered file"

toelli’s picture

I tried this patch and i can't get this to work while my file field is located inside a fieldcollection. Is it just me?

I manage to get this to work for now and in my case by adding a brutally ugly hack to the patched code.

media.fields.inc row 131:

elseif (module_exists('translation') && $element['#entity_type'] == 'node' && translation_supported_type($element['#entity']->type)) {
    $element['#media_parent_entity_form_langcode'] = $element['#entity']->language;
    $element['#media_parent_entity_source_langcode'] = $element['#entity']->language;
  } elseif ($element['#entity_type'] == 'field_collection_item') {
      // Ugly AF but seem to do the job:
      $element['#media_parent_entity_form_langcode'] = $form['#language'];

Any ideas?

Andrew Answer’s picture

Right code is:

  elseif ($element['#entity_type'] == 'field_collection_item') {
    $element['#media_parent_entity_form_langcode'] = $form['#entity']->language;
joseph.olstad’s picture

4.8 KB

Patch #15 rerolled with added condition for field_collection support as per comment #25 by @Andrew

  • joseph.olstad committed ec4a960 on 7.x-2.x
    Issue #2017647 by idebr, Leksat, joseph.olstad, mgifford: Media browser...
joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

fixed in 7.x-2.x dev

Status: Fixed » Closed (fixed)

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