Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.
The Content Translation Support module installs the Content Translation app that allows you to manually export and re-import page content in translation-friendly XLIFF, CSV and Excel formats.
The Content Translation Support module Magnolia 5.3+ allows you to export and import page content in translation-friendly XLIFF, CSV and Excel formats. You can send a file to a translator and import the translated content back. The file includes context information and a link back to the page to make translation easier. Export formats are pluggable and can be extended to support a custom format. The module comes with a Content Translation app.
The Content Translation Support module is bundled with Magnolia and typically already installed. You can download it from our Nexus repository
Content Translation Support is a Enterprise Edition module. It is typically already installed. Launch the Configuration app and go to /modules/content-translation-support
to check.
The module is ready to use and configured at Configuration > /modules/content-translation-support
.
Node name | Value |
---|---|
modules | |
content-translation-support | |
apps | |
config | |
dialogs | |
commands | |
fieldTypes |
The module is fully integrated with the Standard Templating Kit. Your website needs to have at least one locale in addition to the default locale. Locales will show up as columns in the export file. Locales are defined in STK > Site Definitions. Here's the /default
definition with English as the default locale and German and simplified Chinese as additional locales.
Node name | Value |
---|---|
default | |
template | |
themes | |
variations | |
i18n | |
locales | |
en | |
de | |
country | - |
enabled | true |
language | de |
zh_CN | |
country | CN |
enabled | true |
language | zh |
class | info.magnolia.cms.i18n.DefaultI18nContentSupport |
defaultLocale | en |
enabled | true |
fallbackLocale | en |
Importers and exporters are Java classes that contain business logic to convert translatable content into convenient format. Out-of-the-box the module provides importers and exporters for XLIFF, Excel and CSV files, and an exporter for Google Spreadsheets.
Importers and exporters are configured at Configuration > /modules/content-translation-support/config
.
Node name | Value |
---|---|
modules | |
content-translation-support | |
config | |
importers | |
xlsImporter | |
class | info.magnolia.module.contenttranslationsupport.reimport.XlsTranslationBundleUpdateReader |
extension | xls |
label | contenttranslation.fileformat.xls |
csvImporter | |
xliffImporter | |
exporters | |
xlsExporter | |
csvExporter | |
xliffExporter | |
googleSpreadsheetExporter |
Properties:
<importer/exporter name>
class
: Fully qualified name of the class that contains the business logic. See class names below.extension
: File extension without the dot.label
: i18n key of the label that is displayed in the dialog. See Language on how to use keys.Class names:
info.magnolia.module.contenttranslationsupport.reimport.XlsTranslationBundleUpdateReader
info.magnolia.module.contenttranslationsupport.reimport.CsvTranslationBundleUpdateReader
info.magnolia.module.contenttranslationsupport.reimport.XliffTranslationBundleUpdateReader
info.magnolia.module.contenttranslationsupport.export.XlsTranslationBundleWriter
info.magnolia.module.contenttranslationsupport.export.CsvTranslationBundleWriter
info.magnolia.module.contenttranslationsupport.export.XliffTranslationBundleWriter
info.magnolia.module.contenttranslationsupport.export.GoogleSpreadsheetTranslationBundleWriter
You can write your own importers and exporters for other file formats or to store translatable text in a database or send it to a Web service that translators use. See GIT for exporter examples.
There are two sets of equivalent commands. The TranslationFile
commands are used by the app and the exportContent
and importConent
commands are suitable to scheduling and observation.
Commands are configured at Configuration > /modules/content-translation-support/commands
.
TranslationFileDownloadCommand
: website
workspace, in a specified format, for translation. i18n
in the template definitions./demo-project/about/history
page is website.demo-project.about.history
.<file extension>.
TranslationFileUploadCommand
: website
workspace./website
node extends the website
command's catalog to ensure that publication and unpublication of pages is subject to workflow.Node name | Value |
---|---|
modules | |
content-translation-support | |
commands | |
content-translation-support | |
exportContent | |
class | info.magnolia.module.contenttranslationsupport.commands.ExportCommand |
importContent | |
class | info.magnolia.module.contenttranslationsupport.commands.ImportCommand |
importEmptyValues | false |
overwriteExistingValues | false |
downloadTranslationFile | |
class | info.magnolia.module.contenttranslationsupport.commands.TranslationFileDownloadCommand |
uploadTranslationFile | |
class | info.magnolia.module.contenttranslationsupport.commands.TranslationFileUploadCommand |
website | |
extends | /modules/pages/commands/website |
The ContentTranslationSupportModule
class supports two configuration nodes that define the content types that are exported and imported.
controlTypeToExport
: Registers the richText
and text
field definitions. These field types contain the textual i18n content.nodeDataToTransferFinder
: The STKDialogBasedNodeDataToTranslateFinder
class is a STK-specific finder class that finds the relevant i18n content.Node name | Value |
---|---|
modules | |
content-translation-support | |
config | |
importers | |
exporters | |
controlTypesToExport | |
richText | info.magnolia.ui.form.field.definition.RichTextFieldDefinition |
text | info.magnolia.ui.form.field.definition.TextFieldDefinition |
nodeDataToTranslateFinder | |
class | info.magnolia.module.contenttranslationsupport.export.STKDialogBasedNodeDataToTranslateFinder |
The Content Translation app allows you to manually export pages for translation and re-import translated pages. You can also preview and publish pages. The app is available at Tools > Content Translation .
We use the googleSpreadsheetExporter
exporter to demonstrate. The GoogleSpreadsheetTranslationBundleWriter
exporter class adds the Google translate formula to the CSV exporter. When you upload the CSV file to Google Docs it evaluates the formula and the text is machine-translated into the target i18n languages automatically.
To export content:
The download filename is created from the file path in the website
workspace, with dots replacing forward slashes. In our example website.demo-project.about.history.csv
. The file has the following columns (comma separated headings in CSV or elements in XLIFF):
Text and Image: Subheading
. This tells the translator what kind of page element he is translating.You can upload the file to Google Docs for automatic machine-translation, or to give your translator a useful starting point. In Google Docs ensure that you have the Settings > Upload Settings > Convert documents, presentations, spreadsheets, and drawings to the corresponding Google Docs format option selected. Here's the History page in Google Docs. You can now download the file and save it as a CSV file for import into Magnolia.
Once the file has been translated you can upload it in the app. The translated content is automatically included on the page.
To import translated content:
In the Pages app you can now see the translated content in the components and dialogs.
You can view the translated content in the website
workspace in Tools > JCR. Here the page properties for the History page. The translated content is suffixed with a language identifier, _de
and zh_CN
in our example. Since English is the default language on this site no _en
identifier is used.
Node name | Value |
---|---|
history | |
extras | |
promos | |
base | |
footer | |
content | |
metaNavigation | |
comments | |
abstract | This is the abstract for the History page. It is a brief... |
abstract_de | Dies ist die Zusammenfassung für die Geschichte-S... |
abstract_zh_CN | 这是一个抽象的历史页面。是页的内容的简要介绍。摘... |
categories | [d7ba9d64-b7b8-4b93-8a3d-ecd14a049bb8, 248f71e9... |
hideInNav | false |
imageLocation | above |
title | History |
title_de | Geschichte |
title_zh_CN | 历史 |
You can use the Scheduler module to schedule translation export and import jobs.
Here is an example export job that exports content from /demo-project/news-and-events
to an Excel file on the local computer at midnight. You need to pass the following parameters under the params
node:
exporter
. File format to save in. Choose xlsExporter
for Excel, csvExporter
for CSV or googleSpreadsheetExporter
for CSV suitable for Google Docs.file
. Path and file name where to save the exported data.path
. Content to export. This is a path in the website
workspace. All pages under the branch will be exported.Node name | Value |
---|---|
modules | |
scheduler | |
config | |
jobs | |
newsTranslation | |
params | |
exporter | xlsExporter |
file | /Users/Shared/newsExport.xls |
path | /demo-project/news-and-events |
active | true |
catalog | contenttranslationsupport |
command | exportCommand |
cron | 0 0 0 * * * |
description | Export news content for translation |
Here is an example of an import job that imports the same Excel file once it has been translated.
Node name | Value |
---|---|
modules | |
scheduler | |
config | |
jobs | |
newsTranslationImport | |
params | |
file | /Users/Shared/newsExport.xls |
importer | xlsImporter |
path | demo-project/news-and events |
active | true |
catalog | contenttranslationsupport |
command | importCommand |
cron | 0 0 0 * * * |
description | Import translated news content |
You can use the Observation module to listen for changes in the website
workspace and execute the ExportCommand
command when they occur.
Here's an example configuration that executes the ExportCommand
command when a new page is added in the About section of the demo-project
website.
Node name | Value |
---|---|
observation | |
config | |
listenerConfigurations | |
exportForTranslation | |
listener | |
command | |
class | info.magnolia.module.contenttranslationsupport.commands.ExportCommand |
params | |
exporter | xlsExporter |
file | /Users/Shared/export.xls |
path | demo-project/about |
class | info.magnolia.module.observation.commands.RestrictToNodeTypeEventListener |
nodeType | mgnl:contentNode |
active | true |
description | Export articles for translation |
eventTypes | NODE_ADDED |
includeSubNodes | true |
path | /demo-project/about |
repository | website |