How to make template language independent
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
How to make template language independent
Description of the problem
When you create a template (for Impress for example), many informations are stored in your file. If you want to share it in an international environment (propose it to template site for instance), you need to remove all information about your localization (language, money unit, date format...). Otherwise, user need to modify language of many styles in each master page. If template was created by a German speaking user, orthography checking will be done in German.
This how-to explains how to remove all these informations (plus some extras), so that a new user opening this template will have orthography checking in his own language, whatever the language of the template's creator.
Prepare your template
Edit your template in Impress:
- Remove all written text, such as "Write your text here"
- Let only empty layout boxes
- Remove date, footer text
- Remove unused styles; user defined styles won't be translated. Refrain from using them and prefer predefined styles
- Remove text in Notes also
- Save it as template
Choose your preview image
In the template manager, a preview of the template is visible. You may want a clean preview, without reference to any language:
- Open the template to create a new presentation
- Choose the slide you want to see in the preview
- if you have several slides in your template, move to first position the slide you want to see in preview
- Insert "Lorem Ipsum" text in title and text to have an overview of the font used in your template. "Lorem Ipsum" text may be generated in Writer, thanks to an autotext: hit lorem + F3
- Save your presentation as standard ODP file. Let's name it
example.odp
.
Modify XML code
XML code
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 and modification of a template file
For an Impress template you will get a structure like this:
Configurations2
directory should be removed. It may be empty or contain modifications of the configuration in menu bars or short keys. User may prefer to keep his own configuration when using your templateMETA-INF
directory contains only one filemanifest.xml
. This file contains the list of files in the template. Edit it and remove any reference toConfigurations2
if you removed it.Pictures
directory contains all images used in the template. Check if you really need all these images. If you remove some, updatemanifest.xml
.Thumbnails
directory contains preview image. We will update it later.content.xml
file should not need to be modified if you correctly clean your template in Impress. You may check if there is no text.meta.xml
file contains general information of file: date of creation, authors, version used to build it... Nothing to change here.mimetype
is a text file describing the type of the file. It should contains:
application/vnd.oasis.opendocument.presentation-template
- It is useful for OS detecting type of the file
The main part of cleaning is to be done in the two following files. If your file has a long history, you may find many useless things.
settings.xml
file contains the settings of many option you used when you created the template. However, many of these settings are useless for the user, or the user may prefer different options (printer settings, grid and snap options...). Check all options if you want to impose some. Otherwise you may safely remove the file (updatemanifest.xml
) to let user uses its own settings.styles.xml
file contains all styles used in the template.- Search and remove language and country tags:
fo:language="xx"
fo:country="XX"
style:language-asian="xx"
style:country-asian="XX"
style:language-complex="xx"
style:country-complex="XX"
- Complete font size, weight and style for Asian and complex tags (these tags need to be duplicate; see tdf#114746):
- Add
style:font-size-asian="xxpt" style:font-size-complex="xxpt"
for eachfo:font-size="xxpt"
- Add
style:font-weight-asian="wwwww" style:font-weight-complex="wwwww"
for eachfo:font-weight="wwwww"
- Add
style:font-style-asian="sssss" style:font-style-complex="sssss"
for eachfo:font-style="sssss"
- Add
- Search and remove language and country tags:
Change preview picture
- Unzip
example.odp
- Copy
thumbnail.png
file inThumbnails
directory - Paste it in the directory of the template to replace it
Build template file
Simply zipping all directories and files of the template in a zip file will create a template that LibreOffice will be able to open. However this file would not be valid as mimetype
file will be zipped and randomly placed in the file. To get a valid OpenDocument file, you need to place it at the beginning of the file without compression.
Under Windows
To obtain such file, you may read How to of Regina Henschel.
Under Linux
Unzip is simply done from file manager: right clic on file ▸
.To re-zip, you can use following commands in console in the directory containing mimetype
file:
zip -0 -X ../template2.otp mimetype zip -r ../template2.otp * -x mimetype
First line creates a new zip file, with only mimetype
file, without compression.
Second line adds all other files recursively, except mimetype
file, with standard compression
Test your template
Your template is now ready to be tested before diffusion. Make sure it is valid against ODF 1.3.extended, as far as possible. Validator is https://odfvalidator.documentfoundation.org/.
Contribution to LibreOffice code
Procedure to contribute your template is described in README file here.