Translations / i18n
i18n, language specific configurations and the translation files
You are viewing an older version of this documentation page. A newer version is available here.
Kimai can be localized to any language and is already translated to Arabic, Czech, Danish, German, German (Swiss), Greek, English, Esperanto, Spanish, Basque, Persian, Finnish, Faroese, French, Hebrew, Croatian, Hungarian, Indonesian, Italian, Japanese, Korean, Norwegian (Bokmål), Dutch, Panjabi, Polish, Portuguese, Portuguese (Brazilian), Romanian, Russian, Slovakian, Slovenian, Swedish, Turkish, Ukrainian, Vietnamese, Chinese (traditional), Chinese (simplified)
Feel free to send your self-made language files or contributing to the weblate project below – we’re looking for translators and would appreciate your support!
Languages and translations in Kimai are configurable. Read below how to add a new language and configure the output formats for date and time values.
Language files
We try to separate translations in logical units, in order to make it easier to identify the location of application messages.
- If you add a new key, you have to add it at least in the
en
version (as english is the fallback language for all missing keys in any language) - It’s very likely that you want to edit the file
messages
as it holds the most important application translations
The files in translations/
as a quick overview:
about
- the about screen with license informationactions
- the “action” dropdowns in all data-tablesemail
- contents for the system emails generated by Kimai (eg. user registration and password reset)daterangepicker
- the date range picker dialog to choose a timeframe in screens with data-tablesexceptions
- error pages and exception handlersflashmessages
- success and error messages (alerts), which will be shown after submitting datainvoice-calculator
- invoice calculator types (seeAdding invoice calculator
in developers-section)invoice-numbergenerator
- invoice calculator (seeAdding invoice-number generator
in developers-section)invoice-renderer
- holds translations of all invoice templates (read more)messages
- most of the visible application translations (like menu, buttons and forms)plugins
- the plugin screensystem-configuration
- all system configuration, which can be changed through the UItags
- the tags administration screenteams
- the team administration screenvalidators
- related to violations/validation of submitted form data (or API calls)
If you apply changes to any files mentioned on this page, you have to clear the cache.
Authentication screens
The authentication screens (login, registration, register account) are translated through the theme bundle which is used in Kimai. The bundle can be found here and the translations in this directory.
When you create a new translation, please open a Pull Request in this repository as well.
Adding a new language
In the next section I will explain how to add a new language with the (not existing) locale xx
.
Add translations
Copy each translation from it’s english version translations/*.en.xlf
and rename them to translations/*.xx.xlf
.
Adjust the target-language
attributes in the file header, as example for the new file exceptions.xx.xlf
:
<file source-language="en" target-language="xx" datatype="plaintext" original="exceptions.en.xlf">`
Adding a language variant
For a language variant xx_YY
, the fallback will always be the base language xx
(eg. de
for de_CH
).
Only some specific keys may need to be changed for this variant and its possible to add only the respective files like i.e. translations/messages.de_CH.xlf
including only the changed translations:
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="de" target-language="de-CH" datatype="plaintext" original="messages.en.xlf">
<body>
<trans-unit resname="action.close">
<source>action.close</source>
<target>Schliessen</target>
</trans-unit>
</body>
</file>
</xliff>
Configure locale formats
Adjust the file config/packages/kimai.yaml
and add the language (or the language variant) settings below the key kimai.languages
:
kimai:
languages:
# copy all settings from 'en' and adjust them to your language
xx:
date_time_type: 'yyyy-MM-dd HH:mm'
date_type: 'yyyy-MM-dd'
date: 'Y-m-d'
date_time: 'm-d H:i'
duration: '%%h:%%m h'
This is not necessary if your language uses the same configuration like en
, which will be used as fallback.
You only have to overwrite the keys that are different, so if you new language xx
only has a different duration format, then adding this is sufficient:
kimai:
languages:
# copy all settings from 'en' and adjust them to your language
xx:
duration: '%%h hours and %%m minutes'
Register locale
Add the new locale (or the locale variant) in the file config/services.yaml
at parameters.app_locales
divided by a pipe:
parameters:
locale: en
app_locales: en|de|ru|it|xx
Import frontend locales
You can skip this step, we will do it with when we test your changes.
Make sure the new locale is included in the frontend dependencies. For example Kimai includes moment.js, which ships its own translations.
Kimai ONLY compiles the moment.js locales which are needed.
Check and adapt the JS files in the assets/
directory:
- app.js
const Moment = require('moment'); global.moment = Moment; require('moment/locale/xx');
- calendar.js
require('fullcalendar'); require('fullcalendar/dist/locale/xx');
Be careful with the naming of language variants, in JS the variants are written like xx-yy, not xx_YY. To be sure please check the moment.js locales.
Number formats
The number formats on the Kimai frontend as well as in the invoices are defined by the frontend locales. If you get wrong decimal separator or thousands separator keys, please import the correct frontend locale as described above.
Date and time formats
Kimai uses configurations from kimai.yaml
to format the values in the frontend.
It also uses the configurations to convert between javascript components (e.g. the date-picker) and the PHP backend,
so they must create the same output.
AM/PM format
Kimai uses the 24-hour format by default but can be switched to use AM/PM instead, please read the AM/PM format documentation to find out how.
Validate your changes
This will validate if the technical changes are okay / if the changed and new files can be used by Kimai:
bin/console lint:xliff translations
Check for missing translations
You can search for missing keys by issuing this command (replace xx
with your locale):
bin/console debug:translation --only-missing de
or
bin/console translation:update --dump-messages --force de
Finalization
- Sent in a PR with your changes
- Update the documentation, which states all available translations