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

Store translations in the same file #524

Open hdodov opened 4 years ago

hdodov commented 4 years ago

This idea builds on top of #523 and is about translation management. It might be more beneficial to store translations in the same file like this:

title:
  en: Site
  de: Seite
  bg: Сайт

Yes, you'd have to parse YAML, but with the current setup, you have to parse an entire new file and then merge it on top of the default content. The benefits of this setup are:

How would it work?

By using a prefix in the field key. For example, title is a regular field, title:lc is a localized field. The YAML spec allows for that. So you could have:

title:lc:
  en: Site
  de: Seite
  bg: Сайт
toggle: true

...and the title would be parsed because it ends with :lc, meaning that array values are treated as translations. The toggle would be interpreted as-is because it doesn't end with :lc due to translate: false, for example.

With this setup, you could very easily switch the default language too - it would just be a matter of which array key to look up.

bastianallgeier commented 4 years ago

Just to let you know: I removed Kirby 4 from the title to not give the impression in the ideas repo that Kirby 4 is on the horizon. This is far far in the future.

lukasbestle commented 4 years ago

So far we don't need to discuss this for the reasons @bastianallgeier mentioned (by the time Kirby 4 is on the horizon, our opinions will have changed anyway), but just so that you know why we currently use a file per language:

Of course this doesn't need to stay like this forever, so we'll see once it becomes relevant. Your reasons are definitely valid. :)