I can't make message work for now without this fix : (French website)

<?php
/**
 * Implements hoot_entity_load();
 */
function hook_entity_load($entities, $type) {
  if ($type ==  'message' || $type == 'message_type') {
    foreach($entities as $entity) {
      if (!isset($entity->language)) {
        $entity->language = 'fr';
      }
    }
  }
}
?>

Comments

amitaibu’s picture

Category: bug » support
Status: Active » Fixed
StatusFileSize
new38.86 KB

The message field is translatable, so you should make sure you populate the correct text in every language. So you will not need your workaround.

Add message type.jpg

bennetteson’s picture

I try it, take a look :
screen - 1

screen - 2

screen - 3

I try to find where the code fail, I see in the function entity_metadata_field_get_language that the selected language come back to LANGUAGE_NONE whatever the current language of the user.

<?php
/**
 * Helper for determining the field language to be used.
 *
 * Note that we cannot use field_language() as we are not about to display
 * values, but generally read/write values.
 *
 * @param $fallback
 *   (optional) Whether to fall back to the entity default language, if no
 *   value is available for the given language code yet.
 *
 * @return
 *   The language code to use.
 */
function entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE) {
  // Try to figure out the default language used by the entity.
  // @todo: Update once http://drupal.org/node/1260640 has been fixed.
  $default_langcode = isset($entity->language) ? $entity->language : LANGUAGE_NONE;

  // Determine the right language to use.
  if ($default_langcode != LANGUAGE_NONE && field_is_translatable($entity_type, $field)) {
    $langcode = ($langcode != LANGUAGE_NONE) ? field_valid_language($langcode, $default_langcode) : $default_langcode;
    if (!isset($entity->{$field['field_name']}[$langcode]) && $fallback) {
      $langcode = $default_langcode;
    }
    return $langcode;
  }
  else {
    return LANGUAGE_NONE;
  }
}
?>

I will try on a fresh install and update this issue.

bennetteson’s picture

Don't work on a fresh install to.

my config :

Drupal 7.12
local enabled with english and french.
French as default language.

 Chaos tool suite  Bulk Export (bulk_export)                                    Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Chaos tools (ctools)                                         Module  Enabled        7.x-1.0-rc1        
 Chaos tool suite  Chaos Tools (CTools) AJAX Example (ctools_ajax_sample)       Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Chaos Tools (CTools) Plugin Example (ctools_plugin_example)  Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Custom content panes (ctools_custom_content)                 Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Custom rulesets (ctools_access_ruleset)                      Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Page manager (page_manager)                                  Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Stylizer (stylizer)                                          Module  Not installed  7.x-1.0-rc1        
 Chaos tool suite  Views content panes (views_content)                          Module  Not installed  7.x-1.0-rc1        
 Core              Aggregator (aggregator)                                      Module  Not installed  7.12               
 Core              Block (block)                                                Module  Enabled        7.12               
 Core              Blog (blog)                                                  Module  Not installed  7.12               
 Core              Book (book)                                                  Module  Not installed  7.12               
 Core              Color (color)                                                Module  Enabled        7.12               
 Core              Comment (comment)                                            Module  Enabled        7.12               
 Core              Contact (contact)                                            Module  Not installed  7.12               
 Core              Content translation (translation)                            Module  Not installed  7.12               
 Core              Contextual links (contextual)                                Module  Enabled        7.12               
 Core              Dashboard (dashboard)                                        Module  Enabled        7.12               
 Core              Database logging (dblog)                                     Module  Enabled        7.12               
 Core              Field (field)                                                Module  Enabled        7.12               
 Core              Field SQL storage (field_sql_storage)                        Module  Enabled        7.12               
 Core              Field UI (field_ui)                                          Module  Enabled        7.12               
 Core              File (file)                                                  Module  Enabled        7.12               
 Core              Filter (filter)                                              Module  Enabled        7.12               
 Core              Forum (forum)                                                Module  Not installed  7.12               
 Core              Help (help)                                                  Module  Enabled        7.12               
 Core              Image (image)                                                Module  Enabled        7.12               
 Core              List (list)                                                  Module  Enabled        7.12               
 Core              Locale (locale)                                              Module  Not installed  7.12               
 Core              Menu (menu)                                                  Module  Enabled        7.12               
 Core              Node (node)                                                  Module  Enabled        7.12               
 Core              Number (number)                                              Module  Enabled        7.12               
 Core              OpenID (openid)                                              Module  Not installed  7.12               
 Core              Options (options)                                            Module  Enabled        7.12               
 Core              Overlay (overlay)                                            Module  Enabled        7.12               
 Core              Path (path)                                                  Module  Enabled        7.12               
 Core              PHP filter (php)                                             Module  Not installed  7.12               
 Core              Poll (poll)                                                  Module  Not installed  7.12               
 Core              RDF (rdf)                                                    Module  Enabled        7.12               
 Core              Search (search)                                              Module  Enabled        7.12               
 Core              Shortcut (shortcut)                                          Module  Enabled        7.12               
 Core              Statistics (statistics)                                      Module  Not installed  7.12               
 Core              Syslog (syslog)                                              Module  Not installed  7.12               
 Core              System (system)                                              Module  Enabled        7.12               
 Core              Taxonomy (taxonomy)                                          Module  Enabled        7.12               
 Core              Testing (simpletest)                                         Module  Not installed  7.12               
 Core              Text (text)                                                  Module  Enabled        7.12               
 Core              Toolbar (toolbar)                                            Module  Enabled        7.12               
 Core              Tracker (tracker)                                            Module  Not installed  7.12               
 Core              Trigger (trigger)                                            Module  Not installed  7.12               
 Core              Update manager (update)                                      Module  Enabled        7.12               
 Core              User (user)                                                  Module  Enabled        7.12               
 Development       Devel (devel)                                                Module  Enabled        7.x-1.2            
 Development       Devel generate (devel_generate)                              Module  Not installed  7.x-1.2            
 Development       Devel node access (devel_node_access)                        Module  Not installed  7.x-1.2            
 Message           Message (message)                                            Module  Enabled        7.x-1.1+21-dev     
 Message           Message example (message_example)                            Module  Not installed  7.x-1.1+21-dev     
 Other             Entity API (entity)                                          Module  Enabled        7.x-1.0-rc1+42-dev 
 Other             Entity tokens (entity_token)                                 Module  Not installed  7.x-1.0-rc1+42-dev 
 Views             Views (views)                                                Module  Enabled        7.x-3.3            
 Views             Views UI (views_ui)                                          Module  Not installed  7.x-3.3            
 Core              Bartik (bartik)                                              Theme   Enabled        7.12               
 Core              Garland (garland)                                            Theme   Disabled       7.12               
 Core              Seven (seven)                                                Theme   Enabled        7.12               
 Core              Stark (stark)                                                Theme   Disabled       7.12  

files :
drupal : http://cl.ly/2I3i0i0V2d0Y2f2M3N1X
sql : http://cl.ly/0Q2D3t190k11093a0I0O

bennetteson’s picture

bennetteson’s picture

Category: support » bug
bennetteson’s picture

Title: Look like message does'nt work on multilang sites » Message does'nt work on multilang sites
amitaibu’s picture

Category: bug » support

I am using Message on few mutli-langual sites, so defiantly it works, we just need to understand what doesn't work on your setup -- setting to support so it won't intimidate other users ;).
The entity API you are using looks a but old, espcialy considering this related issue -- #1376126: Fix language handling for translatable fields. Try to update to -dev version, and re-try.

bennetteson’s picture

The entity API I use is the lastest dev version (Feb 28).
I think the entity API is too new and make message having this bug.
But I must use the One of the lastest dev version, one of my patch was merged into it, and I must use it.

I will try a oldest dev version of entity API.

amitaibu’s picture

bennetteson’s picture

Yes I suppose, I'm following this thread. Thx for your help.

amitaibu’s picture

Please try with latest Entity API -dev and with this patch -- #1461208: Add "language" property to message-type and message

amitaibu’s picture

Can you provide a db dump, with anything not related to message disabled (I couldn't import the one in #3 for some reason)?

bennetteson’s picture

Status: Active » Fixed
StatusFileSize
new20.03 KB

Look like it's fixed.

screen 1

Tkx

Status: Fixed » Closed (fixed)

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