I did a fresh minimal installation of drupal 7.14.

I only added
Countries 7.x-2.0+5-dev (2012-Jun-23)
Entity API 7.x-1.0-rc3
Entity Translation 7.x-1.0-alpha2

In 'admin/modules' I switched on 'Countries' and 'Entity Translation'.

When I check 'Country' under 'Translatable entity types' in 'admin/config/regional/entity_translation'
I get the Error:
'The entities of type Country do not define a valid base path: it will not be possible to translate them.'

Do I need some additional modules or configuration or is it a bug?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alan D.’s picture

I think that the countries_i18n sub-module would handle all of the main property translations, are you also trying to set translatable fields on the countries entity?

There is a bundle path defined on the entity bundle, but I'll download the translation module to see what it is complaining about.

i.e.

/**
 * Implements hook_entity_info().
 */
function countries_entity_info() {
  $return = array(
    'country' => array(
      'label' => t('Country'),
      'bundles' => array(
        'country' => array(
          'label' => t('Country'),
          'admin' => array(
            'path' => 'admin/config/regional/countries',
          ),
        ),
      ),
    ),
  );
  return $return;
}
Alan D.’s picture

OK, the module is not compatible. Firstly, I see that the following is required

/**
 * Implements hook_translation_info().
 */
function countries_translation_info($types = NULL) {
  $info = array(
    'country' => array(
      'translation' => array(
        'entity_translation' => array(
          'base path' => 'admin/config/regional/countries/%country',
          'alias' => FALSE,
// needed??          'access arguments' => array('administer site configuration'),
        ),
      ),
    ),
  );
  return isset($types) ? array_intersect_key($info, $types) : $info;
}

Hopefully nothing else. So if you add this to countries.module and flush your cache, chances are you will get some integration happening. Let me know how it goes and I'll look at adding this to the main module if it works

haegar der schreckliche’s picture

Yes, this helps. The error is gone.

Thanks for the quick response!

Alan D.’s picture

Does it work correctly? I have no testing environment to try :)

haegar der schreckliche’s picture

To be honest, I still did not figure out how to use translation in views which is my use case.
I have a content type with a country field and I have a view which is supposed to display the content with the country field in a different language.
While trying I found this error message and thought it would be good to report.
Therefor I can't say if it works correctly, sorry!

Alan D.’s picture

Category: bug » feature

webflo done the i18n component and created an translated widget for the module + i18n strings support.

I personally wonder if we should drop that and just run every country entity through country_t(). Currently, we can not as this would be constantly generated and performance could be an issue, but if we can get a language based cache of the country entity working then this is going to be the path forward.

The error [aka ET message] is related to the Entity Translation module warning that there is no integration, but leaving open as a feature request

webflo’s picture

The country name is a property. Properties are not translatable with Entity Translation. ET is for fields only. You should look into the title module too.

Alan D.’s picture

Status: Active » Needs review
FileSize
438 bytes

This appears to be the minimal patch to enable integration for the fields. Love some one to test as I do not have an i18n set up!

Alan D.’s picture

Status: Needs review » Closed (duplicate)

Added to #2032835: [META] Finialise i18n issues. Desperately needing reviews from i18n users ;)

SiliconMind’s picture

Status: Closed (duplicate) » Needs work

I'm sorry to reopen, but since i18n does not care about proper language fallback and Entity translation is heading into the core (#1836086: [meta] Entity Translation UI improvements), it would be nice to use it instead of i18n.

Unfortunately your small patch is not enough, because when I try to translate a country Entity translation complains that there are "No translatable fields". Does anyone have any ideas how to integrate Countries module with Entity translation properly?

bdziewierz’s picture

Please refer to attached. It offers integration with Entity Translation for fields. The only issue I am getting is that properties replaced by Title module still don't work as expected. Any suggestions?

plach’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: countries-entity-translation-1660370-11.diff, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: countries-entity-translation-1660370-11.diff, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: countries-entity-translation-1660370-11.diff, failed testing.

czigor’s picture

Status: Needs work » Needs review
FileSize
5.42 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 18: countries-entity-translation-1660370-18.patch, failed testing.

czigor’s picture

Status: Needs work » Needs review
FileSize
5.4 KB

Get rid of ENTITY_TRANSLATION_LANGUAGE_CURRENT in favor of LANGUAGE_NONE since Entity Translation might not be enabled.

mhmd’s picture

the last patch countries-entity-translation-1660370-20.patch gives error

Fatal error: Class 'EntityTranslationCountryHandler' not found in /var/www/html/exbooth/sites/all/modules/entity_translation/includes/translation.handler_factory.inc on line 93

drupal version = "7.x-3.9"
countries version = "7.x-2.3"
entity translation version = "7.x-1.0-beta4"

joelpittet’s picture

@mhmd did you try rebuilding the registry? It looks correct here in files[]

Alan D.’s picture

Or simply running update.php :)

mhmd’s picture

I did drush updb also drush up Even I tried in a clean installation the same error appeared again

Still not working

Andrew Edwards’s picture

The patch at #20 works nicely, so thanks!

One bug I've found is using name_field as a token (I'm using it to give a page title using page manager).

The offending token: %country:name_field

the error:

Notice: Array to string conversion in ctools_context_keyword_substitute() (line 694 of /Websites/ida2/profiles/openethical/modules/contrib/ctools/includes/context.inc).

I spent some time tracking down the cause of the error and it seems that this code (from countries.module line 885 function country_property) is causing the problem:

    default:
      if (!empty($country->$property)) {
        $output = $country->$property;
      }

Basically, $output should be a string. But, because there are multiple languages $country->property for the field name_field is actually an array.

Andrew Edwards’s picture

Hmn, actually. I don't think the code I mentioned in #27 is the problem.
I think the problem is that the function countries_tokens (line 70 countries.tokens.inc) is fiddling around with the content of the tokens name_field and official_name_field.

Here's the offending code:
$replacements[$original] = country_property($country, str_replace('-', '_', $name), '', $sanitize);

Andrew Edwards’s picture

Patch attached including the bug mentioned in #27 and #28