How to use next-i18next - 10 common examples

To help you get started, we’ve selected a few next-i18next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felixmosh / i18next-hmr / examples / next-with-next-i18next / server.js View on Github external
(async () => {
  await app.prepare();
  const server = express();
  server.use(nextI18NextMiddleware(nextI18next));
  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
  console.log(`> Ready on http://localhost:${port}`); // eslint-disable-line no-console
})();
github lovincyrus / cosmonauts-world / server.js View on Github external
(async () => {
  await app.prepare();
  const server = express();

  server.use(nextI18NextMiddleware(nextI18next));

  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
  console.log(`> Ready on http://localhost:${port}`); // eslint-disable-line no-console
})();
github isaachinman / next-i18next / examples / simple / server.js View on Github external
(async () => {
  await app.prepare()
  const server = express()

  server.use(nextI18NextMiddleware(nextI18next))

  server.get('*', (req, res) => handle(req, res))

  await server.listen(port)
  console.log(`> Ready on http://localhost:${port}`) // eslint-disable-line no-console
})()
github pankod / next-boilerplate / server / index.ts View on Github external
app.prepare().then(() => {
    const server = express();

    app.setAssetPrefix(process.env.STATIC_PATH);
    server.use(express.static(path.join(__dirname, "../static")));
    server.use(nextI18NextMiddleware(nextI18next));

    if (process.env.PROXY_MODE === "local") {
        // eslint-disable-next-line global-require
        const proxyMiddleware = require("http-proxy-middleware");
        Object.keys(devProxy).forEach(context => {
            server.use(proxyMiddleware(context, devProxy[context]));
        });
    }

    server.get("*", (req, res) => handler(req, res));

    server.listen(port);

    // eslint-disable-next-line no-console
    console.log(
        `> Server listening at http://localhost:${port} as ${
github SolidZORO / leaa / packages / leaa-www / i18n.js View on Github external
const NextI18Next = require('next-i18next').default;

module.exports = new NextI18Next({
  defaultLanguage: 'zh-CN',
  otherLanguages: ['en-US', 'zh-CN'],
  browserLanguageDetection: true,
  whitelist: ['en-US', 'zh-CN', 'zh', 'en'],
  localeSubpaths: 'foreign',
  // debug: true,
});
github lovincyrus / cosmonauts-world / i18n.js View on Github external
const NextI18Next = require('next-i18next').default;

module.exports = new NextI18Next({
  lng: 'en',
  defaultLanguage: 'en',
  otherLanguages: ['kr', 'cn', 'ru'],
  // https://github.com/isaachinman/next-i18next/issues/523
  localePath: typeof window === 'undefined' ? 'public/locales' : 'locales',
  browserLanguageDetection: true,
  debug: false,
});
github SolidZORO / leaa / packages / leaa-www / i18n.ts View on Github external
import NextI18Next from 'next-i18next';

const NextI18NextInstance = new NextI18Next({
  defaultNS: 'common',
  defaultLanguage: 'zh-CN',
  fallbackLng: 'zh-CN',
  otherLanguages: ['en-US'],
  whitelist: ['en-US', 'zh-CN', 'zh', 'en'],
  localeSubpaths: 'foreign',
  // load: 'currentOnly',
  keySeparator: '###',
  serverLanguageDetection: true,
  browserLanguageDetection: true,
});

export default NextI18NextInstance;

export const {
  appWithTranslation,
github pankod / next-boilerplate / server / i18n.ts View on Github external
// #region Global Imports
import NextI18Next from "next-i18next";
// #endregion Global Imports

const NextI18NextInstance = new NextI18Next({
    defaultLanguage: "en",
    otherLanguages: ["es", "tr"],
});

export const { appWithTranslation, withTranslation } = NextI18NextInstance;

export default NextI18NextInstance;
github pythonkr / pyconkr-web / i18n.ts View on Github external
import NextI18Next from 'next-i18next'

const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'ko',
  otherLanguages: ['en']
})

export default NextI18NextInstance

/* Optionally, export class methods as named exports */
export const {
  appWithTranslation,
  withNamespaces,
  i18n
} = NextI18NextInstance
github felixmosh / i18next-hmr / examples / next-with-next-i18next / i18n.js View on Github external
const NextI18Next = require('next-i18next').default;
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig;

const localeSubpathVariations = {
  none: {},
  foreign: {
    de: 'de',
  },
  all: {
    en: 'en',
    de: 'de',
  },
};

const nextI18Next = new NextI18Next({
  otherLanguages: ['de'],
  localeSubpaths: localeSubpathVariations[localeSubpaths],
});

if (process.env.NODE_ENV === 'development') {
  const { applyClientHMR } = require('i18next-hmr');
  applyClientHMR(nextI18Next.i18n);
}

module.exports = nextI18Next;

next-i18next

The easiest way to translate your NextJs apps.

MIT
Latest version published 5 days ago

Package Health Score

95 / 100
Full package analysis