Hey! Well put, how do I specify the namespace in consuming space and get the translated string from the namespace?
(before you read: I did not test this answer nor did I spend a lot of time thinking about it, but this is the direction I would take)
Either directly:
t("namespace:key")
Or you could expose (instead of t) a function that creates a derived store using i18next's getFixedT:
t
getFixedT
const getT = (ns: string | string[]) => derived([languageStore], $language => (key) => i18n.getFixedT($language, ns)(key));
You would then use it this way:
<script> /// ... const t = getT('myNamespace') </script> {$t("my-key")}
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey! Well put, how do I specify the namespace in consuming space and get the translated string from the namespace?
(before you read: I did not test this answer nor did I spend a lot of time thinking about it, but this is the direction I would take)
Either directly:
Or you could expose (instead of
t
) a function that creates a derived store using i18next'sgetFixedT
:You would then use it this way: