Custom language variables


I’m using languages support for the first time.

I need to use language variables to make some strings translatable in the templates (ex: ‘Skip to content’).

I noticed that it only works if multi-language support is activated. And then the new text files include the language code.

But I don’t need multi-language content just translatable strings in case somebody use the theme in other language.

It this possible to do?

You can only use the language variables, if you have set at least one language in the config.php file.

If you don’t want to enable multi-language support, you can define strings in your config file, using c::set() and c::get() instead of l::set() and l::get().

I see, but in that way I can’t specify different strings for different languages.

I mean something similar to .pot file in WordPres, where you can add a translation for every language.

As an alternative, you could write a plugin with a translation function or class…

1 Like

Ok, I just wanted confirm if Kirby core supports theme translation without multi-language content.



I would add the needed strings as a field (type: text) for every string in the corresponding blueprint, may be of the parent page to avoid the same field on many pages.
Or add these fields on /site/blueprints/site.yml or a hidden admin-page.

Good luck!

That could be the simplest solution.

I like it, but the theme would not be ready for multi-language in case you want to add more languages in the future.

Thank you

If you want that, you can offer two versions of your theme: a one language and a multi language theme.