# Translate panel select box options in front end

**URL:** <https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635>\
**Category:** Questions\
**Tags:** v3\
**Created:** [February 2, 2019, 3:32pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635 "2019-02-02T15:32:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![teh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/teh/32/9669_2.png) [@teh](https://forum.getkirby.com/u/teh)\
**Post date:** [February 2, 2019, 3:32pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/1 "2019-02-02T15:32:18Z")

</div>

(I couldn’t find anything on this topic in the forum and unfortunately this link is dead: [Translate checkboxes, select, … for end-users](https://forum.getkirby.com/t/translate-checkboxes-select-for-end-users/5666))

I don’t quite get what the **best practise** is, when translating `select box` options in the panel via the language files. Or do I use the new query language?

**Best case** would be that if the panel-user changes the language, also the `select box` options change accordingly. (I don’t mean changing the user’s general panel language but with the button next to the settings button.)

I have a **setup** where the panel-user can select a product category via a `select box`. In the frontend the selected option is shown as a string in a simple `<div>`.

It would be cool if you can you point me in the right direction!

Thanks!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 2, 2019, 3:37pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/2 "2019-02-02T15:37:42Z")

</div>

You can set up the values you want to translate in your language files, then use the `t()` helper to fetch those values:

[https://getkirby.com/docs/guide/languages/custom-language-variables](https://getkirby.com/docs/guide/languages/custom-language-variables)

While you can set you option display to different languages, this only takes effect when the user chooses a different user language, not when changing the content language.

So for example, if you have categories like this:

```auto
category:
  label: Category
  type: select
  options:
    option1: Design
    option2: Architecture
    option3: Travel

```

The in your language file:

```auto
<?php

return [
  'code' => 'de',
  'default' => false,
  'direction' => 'ltr',
  'locale' => 'de_DE',
  'name' => 'Deutsch',
  'translations' => [
    'option1' => 'Design',
    'option2' => 'Architektur',
    'option3' => 'Reisen'
  ]
];

```

And in your template:

```auto
<?= t($page->category()->value()) ?>

```

---

<div class="post-metadata">

**Author:** ![teh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/teh/32/9669_2.png) [@teh](https://forum.getkirby.com/u/teh)\
**Post date:** [February 2, 2019, 4:11pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/3 "2019-02-02T16:11:08Z")

</div>

Ah, cool, I didn’t know that you could layer the `t()` and fetch `$page` items. Thanks!

In the panel though, is it possible to have the selected option value displayed as info text in the page list inside pages section?

I tried `info: "{{ page.productcategory }}"`  
and `info: "{{ page.productcategory.value }}"`  
but both display the option not the value.

Thanks for your insight!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 2, 2019, 4:35pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/4 "2019-02-02T16:35:33Z")

</div>

> [@teh](#):
>
> In the panel though, is it possible to have the selected option value displayed as info text in the page list inside pages section?

The value is what is saved in your content file, you probably mean you want to show what the user sees in the select field? Or the translated string?

---

<div class="post-metadata">

**Author:** ![teh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/teh/32/9669_2.png) [@teh](https://forum.getkirby.com/u/teh)\
**Post date:** [February 2, 2019, 5:07pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/5 "2019-02-02T17:07:20Z")

</div>

Ah, yeah! Doesn’t have to be the translated string.  
Like `info: "{{ page.category }}"` would show “Architecture” or “Reisen” next to the page title.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 2, 2019, 5:27pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/6 "2019-02-02T17:27:00Z")

</div>

In a template, you could get the displayed value like this:

```auto
$field = $page->blueprint()->field('category')['options'][$page->category()->value()];

```

So you could create a custom field method and use that to display the desired value.

---

<div class="post-metadata">

**Author:** ![teh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/teh/32/9669_2.png) [@teh](https://forum.getkirby.com/u/teh)\
**Post date:** [February 2, 2019, 5:33pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/7 "2019-02-02T17:33:05Z")

</div>

Thanks!  
Do you think – with the queries-language in the panel – it’s possible to achieve the following? To display the selected option.

![41](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/e/e081773bc326ef935da1089e47ae12e0fa188c44.png)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 2, 2019, 5:34pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/8 "2019-02-02T17:34:53Z")

</div>

Yes, that’s what I think and why I suggested it.

---

<div class="post-metadata">

**Author:** ![teh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/teh/32/9669_2.png) [@teh](https://forum.getkirby.com/u/teh)\
**Post date:** [February 2, 2019, 5:53pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/9 "2019-02-02T17:53:20Z")

</div>

Ah, sorry, I misunderstood.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 2, 2019, 5:56pm UTC](https://forum.getkirby.com/t/translate-panel-select-box-options-in-front-end/12635/10 "2019-02-02T17:56:10Z")

</div>

But if want to display the part of the option that is show in the select (not the part that is saved to file), then you need a custom method, because you can’t use array indices in the query language.
