-
I want to serve static JSON via context as a simple i18n solution, and the Provider/useContext pair only works without islands. #983 tries to get hydration works, but I want to disable them instead. The JSON files are quite large so I don't want to send those to browsers for dynamic language switching, I only want them to be rendered at server side. Is it possible to restrict context to server-side, or should I avoid using context in this use case? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answering my own question, it's not possible but we have a workaround. It's more or less a feature of the islands design. Rather than rendering the i18n terms down the child nodes, you have to counter-intuitively expose children props to upper levels in the virtual DOM. <>
<NavIsland>
<Translate>Nav Item 1</Translate>
<Translate>Nav Item 2</Translate>
<Translate>Nav Item 3</Translate>
</NavIsland>
<Translate>Other text</Translate>
</> |
Beta Was this translation helpful? Give feedback.
Answering my own question, it's not possible but we have a workaround. It's more or less a feature of the islands design.
Rather than rendering the i18n terms down the child nodes, you have to counter-intuitively expose children props to upper levels in the virtual DOM.