DenysVuika / preact-translate

Minimalistic translate (i18n) library for Preact

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In nested routes, JSON 404s

alexmahan opened this issue · comments

When using a nested route, the translation library looks for the JSON relative to the route rather than at the root of the project.

So when on a page that is generated by: <Route path="/trick/:id" component={Trick} />, the url is something like:
http://localhost:3000/trick/3 but the translate library looks for the localization JSON in http://localhost:3000/trick/assets/en.json rather than at the root http://localhost:3000/assets/en.json and it 404s.

Any suggestions on how to use this library on custom routes?

Figured out how to fix this, just needed a forward slash in the root: <TranslateProvider root="/assets" lang={currentLang.locale}>