Translate inside a QRL function? #70
-
Hi, I'm pretty new to Qwik and very excited with the multi-lingual feature provided with import { useTranslate } from "qwik-speak"
// ...
const t = useTranslate()
const fn = $(() => {
return (
<p>{t('app.example.text')}</p>
}) It will return this error message...
The real use cases are probably more complex than this so I couldn't just set a variable to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In Qwik, a QRL is a lazy loaded code snippet, and does not belong to the
There is no equivalent function for
Then I don't understand what is the use case to return jsx inside QRL. In my opinion, you could directly use |
Beta Was this translation helpful? Give feedback.
In Qwik, a QRL is a lazy loaded code snippet, and does not belong to the
component$
. Therefore it is not possible to use hooks, or closure functions liket
: https://qwik.builder.io/docs/advanced/qrl/To translate out of
component$
, you can useinlineTranlate
: https://robisim74.gitbook.io/qwik-speak/library/translate#inlinetranslateThere is no equivalent function for
usePlural
(see #68), so you have to translate in thecomponent$
and pass it to the QRL (and it works also fort
):