i18next / i18next-gitbook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loading translate not working a server side

eeeman1 opened this issue · comments

🐛 Bug Report

HttpApi doesn't work server side (I can't see translations on first page load)

To Reproduce

https://codesandbox.io/s/smoosh-thunder-o0fuw

just add plugin i18next-http-backend specify url to download translation

const NextI18Next = require('next-i18next').default;
import HttpApi from 'i18next-http-backend';
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig;
const path = require('path');

module.exports = new NextI18Next({
  use: [HttpApi],
  backend: {
    loadPath: `https://pobeda37.io/api/gettranslate?lng={{lng}}&ns={{ns}}`,
    crossDomain: true
  },
  otherLanguages: ['de'],
  localeSubpaths,
  localePath: path.resolve('./public/static/locales')
});

Expected behavior

I expected translations to be loaded in the same way on the server side

Your Environment

  • node v14.15.4
  • i18next version: ^14.0.1
  • os: Windows

This is the documentation repo...

regarding using next-i18next open issues -> https://github.com/isaachinman/next-i18next/

having questions -> stackoverflow