getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Language: add default language in single-language sites #408

Open hdodov opened 5 years ago

hdodov commented 5 years ago

Currently, if you run:

$lang = kirby()->defaultLanguage();

...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:

image

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 its config folder and it can be used when there's nothing defined in languages. This would:


In conclusion, my proposal is:

distantnative commented 5 years ago

That sounds like we would force developers ti define a language even when they don’t want to care.

hdodov commented 5 years ago

@distantnative nope, I said:

Those same things that users define in the languages folder under PHP files - Kirby can have one of those in its config folder and it can be used when there's nothing defined in languages.

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.

distantnative commented 5 years ago

Why don’t you flip on multi-language with only one default language?

hdodov commented 5 years ago

For several reasons:

hdodov commented 5 years ago

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:

This is way simpler. One file - one language. Many files - many languages.