-
Hi, with the following translation (svelte plugin): const en: BaseTranslation = {
LINE: {
FOO: 'bar'
},
} Is it possible to access it dynamically from a Goal is to declare base objects like const field = {
label: 'LINE.FOO'
} and access it dynamically from a generic component <script>
export let field
</script>
{$LL[field.label]()} Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @gterras you have the possibility to access it like you would do with any regular object: $LL['LINE']['FOO']()
// or with dynamic keys
const part1 = 'LINE' as const
const part2 = 'FOO' as const
$LL[part1][part2]() Accessing the object via a string split by |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer that's what I was afraid of, I'll try to find another way to inject the category or switch to flat object structure if not easily feasible since I don't want to manually handle this kind of logic. |
Beta Was this translation helpful? Give feedback.
Hi @gterras you have the possibility to access it like you would do with any regular object:
Accessing the object via a string split by
.
is not supported out of the box.You would need to write a custom function in order to do that. It will probably require some additional effort if you want to keep the typesafety in place.