Since image fields aren't supported by content translation this code would probably work with entity_translation but not with standard drupal core & i18n.

$item = $row->_field_data[$view->base_field]['entity']->{$img_field_name}[$lang][0];
$items[] = $item;               

Comments

muschpusch’s picture

StatusFileSize
new923 bytes

There should be a better way to determine if entity_translation is enabled for a specific node but this works.

muschpusch’s picture

Status: Active » Needs review

and forgot to change status...

Status: Needs review » Needs work

The last submitted patch, 1512608-multilang.patch, failed testing.

muschpusch’s picture

StatusFileSize
new908 bytes

ahm... removed dsm() and fatal error...

minoroffense’s picture

Category: bug » feature

I'll have to do some more research into Entity Translation before building it into the module. Or whether it is required at all. Maybe there's a better way to render the fields in the View which would automatically include the language information if the Entity Translation module is already enabled and a language is applied to the fields.

I also wouldn't consider this a bug and more of a feature request. The module doesn't break any core functionality.

Thanks for the patch though! If we end up using Entity Translation, I'll be sure to apply the appropriate attribution to the commit.

muschpusch’s picture

No i think it's the other way around. Drupal core doesn't support translation of image fields which is desirable when having banners with text etc. The current code tries to load a translated image. One possible solution could be depending on entity api which handles that automatically but i'm not sure.

minoroffense’s picture

Version: 7.x-1.0-rc2 » 7.x-1.x-dev

Hmm, well from what I can tell all fields have a language value in their storage array (by default this is set to LANGUAGE_NONE a.k.a. 'und'). Whether Drupal exposes a means to set a language for image fields is another question.

It's also a question of whether I need to do anything special in Flex Slider. There is the possibility that the Views handler isn't coded properly for language selection. I don't know I'd have to do some more research.

I'll schedule this to be included in Flex Slider v1.3 if a change is required to have this work. I'll also look into your suggested modules.

Thanks!

lovaymiklos’s picture

Hi!

A have the same problem...

Any solution?

Thanks!

muschpusch’s picture

The correct way to check would be fiel_is_translatabe I will create new patch tomorrow...

muschpusch’s picture

StatusFileSize
new99.82 KB

field_is_translatable doesn't return the correct value. @lovaymiklos you could apply the patch from #4 or just install entity translation which should fix it. Could you report back if entity translation works?

@minorOffense: have a look at the devel output. This is a default node when added a new language. Maybe i got something wrong but as far as i know drupal core's locale module doesn't support translation of image fields...

gumanist’s picture

Try this patch:
http://drupal.org/node/1536734#comment-5883368

Sorry, that issue should be marked as duplicate, but i found this one later.

gumanist’s picture

Status: Needs work » Needs review

just status update

minoroffense’s picture

@muschpusch Were you using just Locale and Content Translation? Or did you have i18n or Entity Translation enabled at the time.

minoroffense’s picture

Just to bring over a point from the other issue

Yeah the question is what happens when the image field actually does have a language value other than LANGUAGE_NONE (which btw is the value 'und' that you're seeing).

If I apply this patch, it essentially disables internationalized image fields using the Views plugin. There's a potential solution using Entity Translation (see #1512608: multi language support broken).

The real solution would be (as described here http://drupal.org/node/1512608#comment-5874174) to use field_is_translatable() but that seems to always return TRUE (which once again is technically correct, but the language doesn't propagate to the fields from their containing object).

What I would really need is a function like "field_is_translated" or "field_get_language" or something like that. Which may be part of Entity Translation.

This one hurts my brain. Going to have to give it some more thought.

minoroffense’s picture

Status: Needs review » Postponed (maintainer needs more info)

Alright, so I've fixed the default language handling for fields. I've put in LANGUAGE_NONE when loading the image data.

Before I put in anything to support Entity Translation I need to verify that (as described in the code above) that an Entity with a language always has fields of the same language. Since that's what the if statement in the patch is essentially saying.

If someone knows the answer to that question already, feel free to share ;-) Otherwise I'll have to do some reading inside of Entity Translation.

minoroffense’s picture

gumanist’s picture

If you will take a look on my patch (http://drupal.org/node/1536734#comment-5883368), then you will find that solution is to use language handling defined in core.
It already checks LANGUAGE_NONE and enabled languages.
http://api.drupal.org/api/drupal/modules%21field%21field.module/function...

muschpusch’s picture

I don't have the time to test it right now but this could work:

http://api.drupal.org/api/drupal/modules%21field%21field.multilingual.in...

gumanist’s picture

again
http://api.drupal.org/api/drupal/modules%21field%21field.module/function...

Returns the field items in the language they currently would be displayed.

which uses http://api.drupal.org/api/drupal/modules%21field%21field.multilingual.in...

Returns the display language for the fields attached to the given entity.

The actual language for each given field is determined based on the requested language and the actual data available in the fields themselves. If there is no registered translation handler for the given entity type, the display language to be used is just LANGUAGE_NONE, as no other language code is allowed by field_available_languages(). If translation handlers are found, we let modules provide alternative display languages for fields not having the requested language available. Core language fallback rules are provided by locale_field_language_fallback() which is called by locale_field_language_alter().

it is up to you which method to use. but as i see we have the way in drupal core, that allow get a field value in accessible language and this is the correct way to get it.
but it is up to you use own code or reuse available.

minoroffense’s picture

Title: multi language support broken » Enable multi language support for Views style plugin
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Needs work
minoroffense’s picture

Status: Needs work » Closed (won't fix)

I'm going to leave this to Entity Translation to take care of.

  • Commit 33eb31b on 7.x-1.x, youtube, 8.x-2.x, startslide by minorOffense:
    Fix for default Drupal language support for image fields [#1512608]