Create two taxonomy vocabularies:

* tags

* general

Create them in a function in a separate file which is to be included in the paddle profile's hook_install().

Create a variable for the tags vocabulary to indicate that this is a "flat" vocabulary: taxonomy_vocabulary_tags_type = flat

better ideas than "type" are welcome

CommentFileSizeAuthor
#7 taxonomy-multilingual.png70.81 KBcyberwolf

Comments

angel.h’s picture

Status: Active » Fixed
cyberwolf’s picture

Assigned: angel.h » cyberwolf
Status: Fixed » Needs review
cyberwolf’s picture

Status: Needs review » Needs work
$voc = taxonomy_vocabulary_machine_name_load($machine_name);
if (!is_object($voc) && !isset($voc->vid)) {

If $voc is not an object, $voc->vid will be never set, so that condition can be left out.

taxonomy_vocabulary_save((object) array(
        'name' => $vocab['title']['en'],
        'description' => $vocab['description']['en'],
        'machine_name' => $machine_name,
      ));

      $vid = db_query('SELECT vid FROM {taxonomy_vocabulary} WHERE machine_name = :machine_name', array(':machine_name' => $machine_name))->fetchField();

taxonomy_vocabulary_save() will normally add the vid property to the object passed to it, it uses drupal_write_record() internally, so we can retrieve the vid from that property instead of doing an additional database query.

      foreach ($vocab['title'] as $language => $value) {
        // Save the vocabulary name translation.
        i18n_string_translation_update(
          array('taxonomy', 'vocabulary', $vid, 'name'),
          $value,
          $language,
          $vocab['title']['en']
        );

        // Save the vocabulary description translation.
        i18n_string_translation_update(
          array('taxonomy', 'vocabulary', $vid, 'description'),
          $vocab['description'][$language],
          $language,
          $vocab['description']['en']
        );
      }

I'd replace this with a loop over the different properties to translate (name/title, description), then a loop over the languages inside that property, then insert the translation.

Language 'en' needs to be skipped here by the way, as that is our source language.

       'paddle_tags' => array(
      'title' => array('en' => 'Tags', 'nl' => 'Tags'),
      'description' => array('en' => 'Description for Tags', 'nl' => 'Description for Tags'),
      'is_flat' => TRUE,
    ),

Can you replace the Dutch translation by "Trefwoorden (tags)"?

  'paddle_general' => array(
      'title' => array('en' => 'General', 'nl' => 'Algemene'),
      'description' => array('en' => 'Description for General', 'nl' => 'Description for Algemene'),
      'is_flat' => FALSE,

Can you replace the Dutch translation by "Algemene woordenlijst" and the English source by "General vocabulary"?

cyberwolf’s picture

Assigned: cyberwolf » Unassigned
cyberwolf’s picture

Upon installation I get a PHP fatal error:
Call to undefined function taxonomy_vocabulary_machine_name_load()

I assume because the taxonomy module is not listed as a dependency of the paddle profile and thus will not be enabled before our hook_install() implementation is called.

angel.h’s picture

Assigned: Unassigned » cyberwolf
Status: Needs work » Needs review

Should be better now.

cyberwolf’s picture

Assigned: cyberwolf » Unassigned
Status: Needs review » Needs work
StatusFileSize
new70.81 KB

One more thing: the multilingual mode of the vocabularies should be set as showed on the screenshot, so a language can be set on terms that are added to the vocabularies later on.

cyberwolf’s picture

And with additions of #6 also a coding standard violation:

253 Line indented incorrectly; expected 2 spaces, found 0

angel.h’s picture

Strange, I added taxonomy in .info. I guess I didn't commit it.

cyberwolf’s picture

Ok. Tell me when it's ready for review again.

cyberwolf’s picture

Assigned: Unassigned » cyberwolf

I'll quickly fix the remaining issues so we can merge this.

cyberwolf’s picture

Status: Needs work » Fixed

Merged.

Status: Fixed » Closed (fixed)

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