Open davidlewisbates1980 opened 1 month ago
(I see I can do something like this t("questions.1")
, but that's not helpful if I don't know how many items are in the array)
I suppose a workaround for that could be:
{
...
questions: {
count: "3",
list: [
"What is your name?",
"What is your quest?",
"What is the airspeed velocity of an unladen swallow?",
],
},
}
...and then:
const questionList = useScopedI18n("entity.questions");
const numberOfQuestions = parseInt(questionList("count"));
const randomQuestionIndex = Math.floor(Math.random() * numberOfQuestions);
const randomQuestion = questionList(`list.${randomQuestionIndex}` as any); // Cast is necessary to avoid type error
Is it possible to request the subtree from the locale bundle? For example, if I had my locale bundle look like this...
...is there a way of getting all those questions into an object so that I can randomly select one?