Languages and Checkboxe categories

languages

#1

Hello,

I’m struggling with categoris translations with checkbox…

I’m following out this multilanguage-secrets,

I’ve created a structure like this:

fields:
  category:
    label: Category
    type: select
    options:
      design:
        en: Design
        es: Diseño
      travel:
        en: Tourism
        es:  Turismo
      Beauty:
        en: Beauty
        es: Bellezza

But seems that is not working, also by getting value with
<?= l($page->category()->value()); ?>

I don’t know what is wrong! :frowning_face:
thanks a lot for any suggestions


#2

Those blueprint translations only have an effect in the Panel, not for the frontend.

Using the l() method is the right way in a multi-language installation, but requires that you define your translation as language variable in your language files: https://getkirby.com/docs/languages/variables, e.g.

# es.yml
design: Diseño
travel: Turismo
beauty: Belleza
#it.yml
design: Design
travel: Turismo
beauty: Bellezza

Once you’ve done that, you can call your translations like this:

<?= l($page->category()->value()) ?>

#3

Thanks @texnixe,
I’ve tried your solution within no success :frowning:

I was struggled a while, but finally I 've found a way… reading this ur suggestion :
is-there-an-easy-way-to-get-the-label-of-checkboxes

In particular in my /site/languages/en.php I’ve set:

l::set('category.sport', 	'Sport');
l::set('category.web', 		'Web');
l::set('category.chess', 	'Chess');

in article blueprint:

  category:
    label: Category
    type: checkboxes
    options:
      sport:
        en: Sport
        it: Sport
      web:
        en: Web
        it:  Web
      chess:
        en: Chess
        it: Scacchi

and then in my template/snippet:

$cats = $article->category()->split();
$arraycats = $cats;
foreach ( $arraycats as  $category ) {
	echo  l::get('category.' . $category);
}  

it works perfectly! Thanks for ur help! :blush:

I’m just missing something for translate “category” labels in panel… but I think is only a detail


#4

I don’t know why you had to go for the solution with individual l::set() lines, since Kirby 2.4.0 the yaml version should work. But at least it works now.

Note that the translations in your blueprint do depend on the user language, the language doesn’t change, however, when you use the language switcher in the upper right.


#5

Because the other solution it didn’t work for me…
I’ve tried to set up blueprint like in ur suggestion:

#it.yml
design: Design
travel: Turismo
beauty: Bellezza
l::set( array(
'readmore' => 'Continua..',
'previous' => 'Previous',
));

also tried with variables inside array:

#it.yml
l::set( array(
'readmore' => 'Continua..',
'previous' => 'Previous',
'design' => 'Design',
'travel' => 'Turismo',
'beauty' => 'Bellezza',
));

with no success, I didn’t know what was wrong in my code…
maybe… probably… I didn’t understand the difference in printing values between :

<?= l($page->category()->value()) ?>

and

<?php l($page->category()->value()) ?>


#6

l::set goes into a .php file, the example I used is a .yml file. You can’t mix these things.


#7

Damn!
Thanks @texnixe now I mean! I made a big mistake… :sweat:
I’ll try just when i’ll finish to set up my blog with blueprint plugin