Open hdodov opened 5 years ago
That sounds like we would force developers ti define a language even when they don’t want to care.
@distantnative nope, I said:
Those same things that users define in the
languages
folder under PHP files - Kirby can have one of those in itsconfig
folder and it can be used when there's nothing defined inlanguages
.
Kirby can simply provide a default language for developers who don't care. It already does that, actually - in the form of 12 occurrences of 'en'
in the source code. My whole point is to improve that.
At the same time, if I want to have a single-language site with Deutch as the default language, I could simply create languages/de.php
and that's it. If I decide to turn it into multi-language, I just flip the switch in config.php and add more languages.
Why don’t you flip on multi-language with only one default language?
For several reasons:
.de.txt
instead of .txt
I'm testing now and actually, you can define languages/de.php
without setting languages => true
in the config. You indeed set the "default" language of the site with that, but all your files end up with .de.txt
. I don't think that has to happen. You still have just one language.
Docs say the following about the languages
config setting:
Enables language definitions via the Panel
So that doesn't alter the way Kirby treats languages. I think that's good. But apparently, Kirby internally flips the multilang switch on whenever there's a file in site/languages
. I don't think that's correct.
I think it should function like this:
languages
folder or nothing inside of it - Kirby uses its own default language definition for English from kirby/config
languages
- it is used as the default site language instead (nothing appended to txt files)languages
- the site is now multilang and saving content appends the language locale to txt files as needed. Developers should add default => true
to one of the languages or an error is thrownThis is way simpler. One file - one language. Many files - many languages.
Currently, if you run:
...in a single-language site, you get
null
. That doesn't make sense. There's an implicit default language and that's English. Look at this:I believe those 12 literals aren't good design. Those same things that users define in the
languages
folder under PHP files - Kirby can have one of those in itsconfig
folder and it can be used when there's nothing defined inlanguages
. This would:languages
In conclusion, my proposal is:
kirby()->defaultLanguage()
returnsconfig
or the first language in thelanguages
folderkirby()->language()
returnsdefaultLanguage()
kirby()->multilang()
returns whether the site is flagged as multi-language in config.php