i am setting up a new blueprint for my Kirby-Projects and migrate my functionalities from Kirby v2 to v3. So i came up with some questions:
In other CMS like Drupal or so there is something like a taxonomy. Like a Page where you would enter all language variables in every language, which you could then access via Template. That would be very neat, because you wouldn’t have to enter them in the language variable files. But i have seen, that you now could access language variables via YAML files, so could this be possible??
And the second question is: is it possible to only publish one language of a page? I had this usecase quite often when most content is in German and only some of them had translations in let’s say English or Chinese. For v2 i had @flokosiol 's translations plugin, which doesn’t seem to work under v3 anymore. Are there any other approaches you could apply for such a usecase? Just defining a bool for publishing would not be so nice…
Hey Tobi, there’s a draft of the translations plugin for K3 in the Kirby3 Branch. It’s far away from being perfect, but it might help you nevertheless?!
Hey Flo, yeah so far so good. Everything is working out at the moment.
Okay i’ll have a look at the kirby3 branch. Are there any known issues that could affect production? Because you wrote it in the Description?
Unfortunately i get errors with the first test. What is the current state of the Plugin, you’re going to work on it in foreseeable future? Maybe you could tell me what the problems are and i try it by myself and give you a pull request?
Okay thank you. But i have to keep the variables in sync with the template. So if i have a variable let’s say ‘test.variable’ and i say <?= t('test.variable') ?> it gets not updated when i’d change the variable key in the panel, right? Is there a possibility for retrieving all translations-entries and filter them?
Anyway. This is of great help. Thank you so far. I’ll define the use-case tomorrow and have a look how it will work out…
In some place you will have define what sort of variable is used, let’s say you want a button in page. In a field for a button, the user would insert a language variable (button.text). Then in Trevor view, the user would enter the different translations for this variable. You would then get the name of the variable form the the field (or maybe from a custom button kirbytags or whatever.
I think the most common use-case would be the name for a Company. Which could be Test GmbH&Co.KG or whatever and another legal state in English. So instead of keeping track of every single use in the CMS it would be helpful to define them in the variables, use them in templates and even as KirbyTags for the Textareas. So you’d just say <?= t('company.name') ?> or { company.name } in textareas or whatever. But i think it could be possible with the possibilities i now have on hand. I’ll keep you posted. Thanks in advance.
For using it in textareas or other fields, you could render those with KirbyText and use a hook to replace your {company.name} placeholder with the value you want:
Ah, ok, thanks, so that means we can’t use Str::template() when using dots in placeholder keys which is quite common. Anyway, this works using the code from the template() method without the query language check: