How to get language variables in specific language

Example:

// command
l::get('about')->lang('de');
// output
über

Is that possible?

No, that is not supported. Theoretically, the getter supports a locale parameter, but it is not implemented. What is your use case?

I wanted to make a list with translations.

If your language variable files are in yaml format, you can get the strings like this:


$germanStrings = yaml::read(kirby()->roots()->languages() .'/de.yml');
dump($germanStrings);
    
foreach($germanStrings as $key => $value) {
  echo $key . ': ' . $value;
}

I just did it like this:

require($roots->languages() . DS . $code . '.php');
l::get('$message');

It worked for me.

Note that you can simple call l::get() without any parameters to get an array of all the strings. Probably more useful if you want to print a list of all strings.

I’m listing all translations of a single word (at a time).
Your approach will also be very useful.
Thank you.

If you need a translation file: read this
https://getkirby.com/docs/cheatsheet/helpers/l

And i found out on the language switch that you can get the translate url page

I used:
<?php foreach ($site->languages() as $language): ?>
<li class=“menu__language-item”>
<a class=“menu__language-link” href="<?= $page->url($language->code()) ?>">
<?= html($language->code()) ?>
</a>
</li>
<?php endforeach ?>

Thank you. That’s right.