I'm building up a multilingual website (Drupal 7) with Locale and Content translation modules enabled for nodes. The node category is managed thru a content_area field (taxonomy term thru Entity Reference module), which is translated with Entity Translation and Title modules in order to have a translated path in URL (using Pathauto module). Everything goes as expected, the content_area is translated in URL, in the breadcrumb and in the tags area.

As each node manages more images, shared among languages, we've built a file folders structure which comply with paths (not equal but similar) in order to keep a clean images structure, using File (Field) Paths module. Problems arise: if the content_area field (taxonomy term) is untranslated (i.e. English), we have only one folder for images of all languages (as expected), but if we translate the content_area field we get a translated folder keeping images, as we do not want.

When setting up File (Field) Paths for images field in File path, we expected to find a token related to the untranslated/translated [node:field_content_area:name], with no luck. Even [node:source:field_content_area] cannot work and do not work, as we cannot know if the editor building up the node content will begin ('source') from English or from another language.

I hope I have been clear, it is my first post. Thanks in advance

  • Did you try i18n_taxonomy module?
    – Jimmy Ko
    Jul 15, 2016 at 13:07
  • I did try, but when I enabled it, without entity translation, I was not able to get a translated path. Should I try both modules enabled (18n_taxonomy AND entity_translation + title for taxonomy term)? My idea was to look for a token language-related Jul 15, 2016 at 13:31
  • I've tried again the i18n_taxonomy module, together with entity_translation for taxonomy term (we need path translated) and problem with translated folder for images remains, no token for English-only folder to apply to File (Field) Paths Jul 15, 2016 at 15:03

1 Answer 1


Decipher's blog suggested the answer: I initially created a custom module to define a custom token to use in FileField Paths, and then I installed Custom Tokens module, and created same token as before.

Both methods worked, and at the end I'll use second method (installing Custom Tokens module, without my custom module), as it will be easier to create other tokens when needed.

Method 1:

 * Implements hook_token_info().
 * gw_content_area_en is the token used as [node:gw_content_area_en]
function MODULENAME_token_info() {

    $info['tokens']['node']['gw_content_area_en'] = array(
      'name' => t('Gw Content Area EN'),
      'description' => t('English version of field_gw_content_area'),

    // Return associative array of tokens & token types
    return $info;


 * Implements hook_tokens().
function MODULENAME_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  // Check if token type is node
  if($type == 'node'){
    foreach ($tokens as $name => $original) {
      switch ($name) {
        // Check token is gw_content_area_en
        case 'gw_content_area_en':
          $tid = $data['node']->field_gw_content_area[LANGUAGE_NONE][0]['target_id'];
          $term = taxonomy_term_load($tid);
          $replacements[$original] = $term->name_original;
  return $replacements;

Method 2:

  1. Install Custom Tokens module;
  2. Create a new token with following settings:

    • Token name: Gw Content Area EN
    • Token description: English version of field_gw_content_area
    • Token type: Nodes
    • Content:

    $tid = $data['node']->field_gw_content_area[LANGUAGE_NONE][0]['target_id'];

    $term = taxonomy_term_load($tid);

    return $term->name_original;

New custom token used to set FileField Path.

Note: i18n_taxonomy module disabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.