Languages and translations in Kimai are completely configurable. Read below how to add a new language and configure the output formats for date and time values.
We try to keep the number of language files small, in order to make it easier to identify the location of application messages and to unify the codebase.
enversion as well (as english is the fallback language)
messagesas it holds 90% of our application translations
The files in
translations/ as a quick overview:
about- the about screen with license information
daterangepicker- the daterange picker dialog to choose a timeframe in screens with data-tables
exceptions- error pages and exception handlers
flashmessages- success and error messages (alerts), whichwill be shown after submitting data
invoice-calculator- invoice calculator types (see
Adding invoice calculatorin developers-section)
invoice-numbergenerator- invoice calculator (see
Adding invoice-number generatorin developers-section)
invoice-renderer- holds translations of all invoice templates (read more)
messages- most of the visible application translations (like menu, buttons and forms)
pagerfanta- includes the translations for the pagination component below data-tables
plugins- the plugin screen
system-configuration- all system configuration, which can be changed through the UI
validators- related to violations/validation of submitted form data (or API calls)
When you create a new translation, please open another PR there as well.
As example I choose a new hypothetical language with the locale
Copy each translation from it’s english version
translations/*.en.xliff and rename them to
target-language attributes in the file header, as example for the new file
<file date="2018-08-01T20:00:00Z" source-language="en" target-language="xx" datatype="plaintext" original="exceptions.en.xliff">`
Adjust the file
config/packages/kimai.yaml and add the language settings below the key
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'
Append the new locale in the file
parameters.app_locales divided by a pipe:
parameters: locale: en app_locales: en|de|ru|it|xx
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, e.g. app.js:
const Moment = require('moment'); global.moment = Moment; require('moment/locale/xx');
Kimai uses the configurations in
kimai.yaml to format the values in the frontend.
so they must create the same output.
Kimai uses 24 hour format by default. If you want to use the 12 hour am/pm format, you have to adjust the locale config at the key
24_hours like this:
kimai: languages: en: date_time_type: 'yyyy-MM-dd hh:mm a' date_type: 'yyyy-MM-dd' date: 'Y-m-d' date_time: 'm-d H:i' duration: '%%h:%%m h' time: 'h:i a' 24_hours: false
You can search for missing keys by issuing this command (replace
de with your locale):
bin/console debug:translation --only-missing de