Closed minimalweb closed 3 years ago
The third $locale
param was actually for a different feature, which has been removed (apparently we forgot to remove the third param, which isn't used by the method anymore).
The feature was never intended to get a variable from a different language. That's actually not possible as Kirby only loads the locale file of the current language. What is your use-case where you need the variable in a different language?
People can subscribe to a newsletter and pick one or two languages (or both) in which they want to receive it. For both languages, a salutation will be sent to the newsletter service. So regardless, of the language the website is viewed in at that moment, I need to get the salutation for both languages.
But the rest of the newsletter in the two languages is handled by the newsletter service? If so, you might as well handle the salutation there as well?
If you really need the salutation in both languages from Kirby, instead of using the language variables, you can use set an array in your config.
c::set('lang-variables', [
'salutation' => [
'en' => 'Hi',
'de' => 'Hallo'
]
]);
$variables = c::get('lang-variables');
$germanSalutation = $variables['salutation']['de'];
$englishSalutation = $variables['salutation']['en'];
Just wanted to write the same as @texnixe. :)
I'm leaving this issue open because of the documentation issue, but if you have any further questions about your use-case, please ask in the forum.
Thanks for the quick replies. Unfortunately, the newsletter service cannot handle the salutation in an intelligent way, so I will use the config settings.
If for example, I have set up two languages and want to do something like this:
Both would output the same string, based on the current site locale and not based on the locale you have provided as an argument.