From The Document Foundation Wiki
Jump to: navigation, search

How to internationalize templates

LibreOffice is developed in many languages. Creating templates to be shared with LibreOffice community requires to adapt them to all languages. First of all you must remove all texts in your file:

  • check master page, to remove such text as "Your footer here", "Your title here". If there is no text, LibreOffice will automatically show a text in UI language querying user to add these information
  • check notes of all pages added, to remove all text
  • do not use picture with text that need to be translated

However, even if you remove all text, there still will be some hidden information about your environment stored in the template. For instance, your UI language will be used as default language for spell checking, even if a user of your template used a different language. See tdf#107027.

You then need to modify XML code of templates to remove all language dependent tags, in three main steps:

  • unzip OpenDocument file
  • explore and modify XML code
  • rezip OpenDocument file in a proper manner

Here is a step by step procedure for Impress template, but same should apply to other templates.

Unzip OpenDocument file

Templates have file extension as .OT?, with ? standing for:

  • T = .OTT template for Writer
  • S = .OTS template for Calc
  • P = .OTP template for Impress
  • G = .OTG template for Draw

See What is the file format used by LibreOffice? question to have more details, but in a nutshell, these files formats are simply zipped archive containing a structure with XML files (See LibreOffice and XML). So to access XML code, you need first to unzip OT? file. Use your favorite archive software to unzip. You may need to rename file extension to .ZIP or not depending of your software.

Content of a template file

For an Impress template you will get a structure like this:

  • mimetype: text file containing only one string describing the type of the template. For instance for an Impress template:
  • meta.xml: XML file containing general information about template: author, date of modification, LibreOffice version,...
  • META-INF: directory containing one file:
    • manifest.xml: XML file containing the list of all files in the structure. Be careful to update it if you remove or add files.
  • Configurations2: directory containing specific configuration for keyboard shortcut, menu, toolbar,... It is usually empty.
  • settings.xml: XML file containing specific information for options about printer, grid,... For a more general template, there must be less information in this file.
  • Pictures: directory containing image files used in the template.
  • Thumbnails: directory containing preview picture of the template (for file navigator,...)
    • thumbnail.png: preview of template
  • content.xml: XML file containing description of all the content of the template (master pages, position of title, pictures,...)
  • styles.xml: XML file containing description of styles (master page, paragraph, drawing,...) used in content.xml

Modify XML code

You should use your favorite XML editor to ease exploration. Files that need to be modified:

  • Configurations2: if your template does not modify menu, shortcut or toolbars, this directory should be empty. You can then remove it.
  • manifest.xml: if you removed Configurations2 directory, you must update this file to remove references to this directory.
  • settings.xml: many of these information may be removed, such as printer or grid options. User options should be used, instead of options of your template.
  • content.xml: check this file carefully if there are no more text. The more interesting part is at the end with <office:body> tag.
  • styles.xml: this is the most important file to modify. Check each style and remove all fo:language and fo:country tags.

Rezip OpenDocument file

When you have finished to modify XML files, you need to rezip all the structure to rebuild your template file. However, you cannot simply zip all files in one to create a proper OpenDocument file. In an OpenDocument file, mimetype file must not be compressed and must be placed at the beginning of the zip file. To obtain such file, you may read How to of Regina Henschel.

When you obtained your zip file, you can change its extension back to .OTP to get a template for Impress. However, preview need also to be modified (see tdf#107045).

Modify preview of file

Preview of file was created in LibreOffice, using your UI language. To get an internationalized file, you may replace localized text with Lorem Ipsum text.

  • open your template (do not edit it) to create a new file
  • in Writer, launch Lorem Ipsum AutoText, with lorem F3 to get some sample text
  • if you have several slides in your template, move to first position the slide you want to see in preview
  • type Lorem Ipsum for title
  • paste some Lorem Ipsum text in outline
  • save your presentation foo.odp
  • close LibreOffice
  • unzip foo.odp presentation file
  • copy thumbnail.png file (in Thumbnails directory) and paste it in the structure of the template
  • rezip your template in a proper way as describe upper
  • rename zip file with .OTP file extension

You can now add your template to your template library to check its preview in StartCenter. That's all folks!