lib icon indicating copy to clipboard operation
lib copied to clipboard

Can Arrays be translated?

Open eikaramba opened this issue 3 years ago • 4 comments
trafficstars

I have a list of FAQ entries as an array of objects like

[
  {
  title:"can i do xxxxxx?"
  text:"yes you can"
  },
  .....
]

I wasn't able to translate this, is this possible? it would be nice if i can just create a faq.json put the array there and use it via $t('faqs').

eikaramba avatar Aug 08 '22 16:08 eikaramba

Hi.) Currently it works like:

// faqs.json
{
  faqs: [
    {
      title:"can i do xxxxxx?",
      text:"yes you can"
    }
  ]
}
// page.svelte
$t('faqs.0.title');

jarda-svoboda avatar Aug 08 '22 23:08 jarda-svoboda

yes that works, but the problem is that i am not able to get ALL Faq entries with that approach. basically i just want to retrieve all FAQ entries and filter them based on some query. doing $t('faqs') did not work for me. should it?

eikaramba avatar Aug 09 '22 10:08 eikaramba

Ok, it’s currently not designed to work this way.. However it can be useful so I’m adding it.

jarda-svoboda avatar Aug 09 '22 11:08 jarda-svoboda

wow thanks, yeah that would be great. just had another case were this would be super helpful

eikaramba avatar Aug 10 '22 09:08 eikaramba

Any updates on this? I would really like to be able to do this

Suya1671 avatar Oct 22 '22 19:10 Suya1671

I would really love to see this happen! I need it in projects!

CannonPhelps avatar Jan 12 '23 03:01 CannonPhelps

Tell me please, has not yet appeared a function for enumeration of arrays?

Anastasia199129 avatar Feb 24 '23 13:02 Anastasia199129