Multi-language setting - i18n
Configuring Internationalization
After configuring core modules only, pages like front page (=/node, by default) or blog page (=/blog) show original and translated contents mixed. The i18n module solves this problem. Additionally, you can set up some details like prohibiting language neutral contents.
- Administer > Content management > Content types
- See a section called “Multilanguage options”, for each content types.
It could be more convenient if there were a global configuration and content type just override it.
Synchronizing fields between translations
After a few translations, I find myself wanting to keep some fields like taxonomies (e.g., tags) or URL aliases between original and translated content. In case of taxonomy, (among many i18n modules) “Taxonomy translation” module , besides it allows translating taxonomy, automatically sets up taxonomy field to the same value as original content during adding translation.
“Synchronize translations” (= i18nsync) does the similar jobs for the other fields. Basically, it synchronizes
- informative fields like authors,
- status fields like status, promote, sticky and moderate, and
- fields which need special handling, like revision, taxonomy, and book outlines.
“Synchronization” means that it not only sets up the fields during adding translation, but also updates the fields of other translations after editing any of translations.
To set up synchronization,
- enable the i18nsync module,
- then, a section called “Multilanguage options > Synchronize translations” appears at administration page of each content type,
- select fields to synchronize there.
README file documents how to synchronized other non-default fields, but, at first, I couldn’t figure out exact meaning of “field” and “field name” in the example code. The i18n module documentation was far from useful and googling was not successful either, so I had to spend some time to read the source.
- “field” is field (= attribute) name of
$nodeobject (which, you can’t find out without seeing related modules providing the attribute). - “field name” is string to display at administration page.
Add the following configuration to setting.php to synchronize URL aliases.
‘path’ => ‘URL path settings’,
);
Before editing, writing permission of setting.php should be set (chmod u+w setting.php).
If there are many users, it could be better to make site offline
because it seems that permission of setting.php is reset every time drupal is accessed.
Problem of synchronization, and alternative solution
After all those work, I had to disable the i18nsync module. Automatic filling of fields during first translation works, but synchronizing fields after editing seems to have bugs. To be exact, when the original is saved with URL alias set, then that URL alias is not saved for the original, but instead URL aliases is created for other translations.
Rather than complex synchronization that doesn’t work, I defined the following function to the custom module I’ve made a few days ago.
switch ($op) {
case ‘prepare translation’:
$source = $node->translation_source;
$node->path = $source->path;
break;
}
}
- moonz's blog
- Login to post comments
- 한국어