While developing Babel, I was thinking about mixing up (or better separating) languages and locales, too. It always feels a bit weird, how cockpit detects languages for entries and for the admin ui and where I have to check for default
strings. Also the terms languages
, locales
, i18n
are sometimes a bit confusing to me.
My typical use case is:
- I use Cockpit CMS v1 (v2 is still a play ground for me).
- Personally, I always use English user interfaces. It is annoying to search for German error messages.
- For non-English (or multilingual) front-ends, I provide app i18n files to translate some system messages.
- For German and French clients, I provide app i18n files, so they have a translated user interface.
- It never happened to me, that entry languages should differ from app languages → so thanks for your feedback.
The current implementation is, to
- read
i18n
and languages
from config.php
in cockpit v1 or read $app->helper('locales')->locales();
in cockpit v2,
- strip out
default
strings and
- ignore
'en' => 'English'
, if explicitly set.
languages
and $app->helper('locales')->locales();
are used for entry level languages. Admin ui languages don’t have any detection system besides the existence of <locale>.php
inside config(/cockpit)/i18n
folders.
I think, it would be better to use an explicit config key to read app languages in config/config.php
, e. g.:
<?php
return [
'app.name' => 'My app',
// set entry level languages in cockpit cms v1
// use the gui instead to change locales in cockpit cms v2
'i18n' => 'de',
'languages' => [
'default' => 'Deutsch',
'fr' => 'Francais',
],
// set admin ui languages with an explicit config key
'app.languages' => [
'de' => 'Deutsch',
'fr' => 'Francais',
],
// alternative
'babel' => [
'languages' => [
'de' => 'Deutsch',
'fr' => 'Francais',
],
],
];
Now I’m not sure, how to name that new config key and if I should wrap it into a babel
config key.
And I think, it would be useful to not fallback to the current implementation, which would also eliminate all these checks for default
strings.
@sgirard84 What do you think?