I've been studying the code of the current image module (6.x) trying to find a way to create image translations (translated title and description) without duplicating the files, to be implemented in i18n module (i18n sync)
AFAIK, we would be ok about the data model (we'd just need to create additional rows in the image table), but given how the image module works there's no way we can plug into the image inserts and updates to do it.

As node translation is now a Drupal core feature I think this goes beyond i18n module compatibility being more a missing Drupal core feature when it comes to image nodes.

What we need here is not really the image module handling translations itself, but a way to prevent 'image_insert' from copying files around, when they're already existing files in the 'files' folder so we can do something like:

// This will be done by i18nsync module, if not by the image module itself
$translation->images = $original->images;
$translation->new_file = FALSE;

// and then a way to prevent image insert from copying files
function image_insert() {
  if (!empty($node->new_file)) {
    // do insert operations
 }
 // otherwise, skip, other modules can do their work here and fill in the image table rows reusing a fid...
}

Also for the image_delete() function we'd need a flag to prevent the module from deleting the files (as they may be linked too to other translations).

Please let me know whether this makes sense (I'd be posting a patch) or you can think of a better way of achieving the same.

Related i18n issue: #329825: i18n/image: How to translate a picture? ;) i18nsync_fields_node_image not working

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Title: Alow sharing image files from different modules (image translations) » Allow sharing image files from different modules (image translations)

At which layer does i18nsync perform those alterations? form_alter() or nodeapi('load'/'prepare')? I'm asking, because I only know Translatable's approach and flow, which mostly works in the FAPI layer.

Jose Reyero’s picture

Mostly on nodeapi, but the module is a collection of hacks to support other modules/fields translatability and synchronization, so we take whatever approach is needed by each of the other modules.

Ideally, each node module would take care of its own translations (i.e. for image module, it might copy over the original image using _nodeapi('prepare translation'), but allow it to be replaced as sometimes different translations may mean different images). Well, that may be a feature request too.

As the multilingual support varies for each contrib module, we have this i18nsync module that takes care of all what other contrib modules don't do plus some synchronization (updating all translations when you update one of the nodes)...

sun’s picture

Hm. I still have little idea of what would be required for i18nsync, because I do not know its flow. I can only guess that the node's title and description (body) is already covered in i18nsync's process. Anyway, if you see a way that would make it compatible, please feel free to post a patch.

That said, I guess that it should be configurable per image (node) whether the image file is synced or not. If you consider a technical screenshot of an application, one might want to provide a different screenshot per language, while other images on the site can be happily synced. (That's why Translatable works at the FAPI layer, so it would be basically able to allow more granular translation flows like this)

Jose Reyero’s picture

Status: Active » Needs review
FileSize
3.59 KB

This patch allows sharing image files in translations. What it does in detail:
- When creating a translation, the image is pre-populated with the source node's image (unless a new image is uploaded)
- When updating/deleting a image node, just delete the actual file when it is not linked to any other node

This way, when you create a translation you have the option of keeping the same image or uploading a new one. This is not related to i18nsync, though if this patch gets in I'll be able to add additional sync features on top of it....

AltoRetrato’s picture

I spent days reading documentation, searching with Google and pulling my hair out... and finally I found your patch. It seems to work like a charm. Great job, Jose, and thanks for sharing!

AltoRetrato’s picture

P.S.: Even though I can translate the name and description of images with this patch, I can't find a way to translate the name and description of galleries. I found (Home › Administer › Site building › Translate interface › Search) and tried to translate the taxonomy strings, and also put the t() function in image_galley.module where it was missing (t($gallery->name) and t($gallery->description)), but the title and description always shows up without translation. For now, I'm using string overrides in settings.php, but it is such an ugly hack...

Does anyone know of a better solution?

Jose Reyero’s picture

@AltoRetrato,
>P.S.: Even though I can translate the name and description of images with this patch, I can't find a way to translate the name and description of galleries

This is a completely different issue, unrelated with what this patch does

Thanks for testing the patch

JensVejmand’s picture

Tried out the patch just now: Solves my problem with double-uploading images.

Thanks. Hopes this comes into the Image module.

sun’s picture

I like this patch in general. However, we want to add some tests to ensure that the expected logic works (and keeps working).

sun’s picture

#403142: Keep some info across translations has been marked as duplicate of this issue. I see that this issue implements the possibility to assign a single file to multiple image nodes (translations) while ensuring that the file is not deleted when there is still a node referencing the file left.

metabits’s picture

Please, please...

- Is this ready for production sites?

- Any alternative for those of us who are too ignorant to apply patches and/or are nor able to apply them?

- Any altruist soul wanting to help me applying the patch?

I have a photography site in three languages and also another one in two languages that will have lots of images ! This could make my life much happier !

Thanks in advance !

psc

tomsm’s picture

When will this be added to the Image module?
I need to translate the title of my images.
Thanks!

ikeizer’s picture

What's the status on this? Is this being implemented already? Thanks.

tomsm’s picture

subscribing....

hop’s picture

When I apply this image_translation.patch, I don't see any images with neutral language (explicit language is OK). Thanks a lot

sun’s picture

FileSize
4.09 KB

Re-rolled with some minor adjustments.

I need some positive confirmations that this patch works with Translation module being enabled, but also doesn't break functionality without it.

okokokok’s picture

image_translation.patch from #4 works.
Though the first time saving it didn't store my translated title.

sun’s picture

Status: Needs review » Fixed

I'm trusting your expertise, Jose.

Thanks for reporting, reviewing, and testing! Committed to 6.x.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

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

mnordstrom’s picture

Hi,

I still have this problem. Using the newest version of Image, which should have this patch included, but can't get it to work.

Jose said:
- When creating a translation, the image is pre-populated with the source node's image (unless a new image is uploaded)

...and this does not happen. I click on translate > add translation from the source image, but the image upload field is empty and not pre-populated like it should. If I try to submit the post, it won't let me, since there is no image. Don't really get what can be wrong, should I have any other settings enabled in addition to the normal i18n stuff which allows translating images in the first place?

Happy to tell you more about my settings and modules if this isn't enough.

mnordstrom’s picture

Category: feature » support
Status: Closed (fixed) » Active
mnordstrom’s picture

Category: support » feature
Status: Active » Closed (fixed)

This got fixed by updating to the latest dev versions of the Image module and the i18n module.

jagdfalke’s picture

Category: feature » support
Status: Closed (fixed) » Active

This patch doesn't seem to do anything over here.

I'm using image-6.x-1.0-beta3 and i18n-6.x-1.1 with Drupal 6.14. When I click on "add translate" for an image node, the form to create the translated note doesn't contain an image.

Do I need to use the dev version of i18n?

Regards,
Milan

Jose Reyero’s picture

Status: Active » Closed (fixed)

@jagdfalke
Wait for next versions of both modules.

sun’s picture

Category: support » feature
Status: Closed (fixed) » Fixed

@Jose: Any time-frame or similar for the next release of i18n? :) AH! And btw: #549698: Prepare field label and description for DDT (translatable queries) - see you over there! :-D

Status: Fixed » Closed (fixed)

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

vronkdaut’s picture

I have now i8n 1.2 and image 1.0-beta4

but i still can't translate the images (reusing the existing image in the translation).

Should this be working now? Any ideas what I have to check?
Shall the i18n-Synchronization module take care of it?

UPDATE: sorry, mea culpa. was trying with wrong role.
Works like a charm after activitating admin/content/node-type/image: Multilang opts/Sync translations/Image Files.

Matej