Internationalization (i18n) for Deno with i18next

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • i18next-fs-backend

    i18next-fs-backend is a backend layer for i18next using in Node.js and for Deno to load translations from the filesystem.

  • Alternatively, use i18next-locize-backend instead of the i18next-fs-backend. If you're running your code in a serverless environment, make sure you read this advice first!

  • i18next

    i18next: learn once - translate everywhere

  • We will show some examples that uses i18next as i18n framework. If you're curious to know why we suggest i18next, have a look at this page.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • locize-cli

    locize cli to import / export locales, add / edit / remove, sync segments

  • Just use this cli to synchronize the translations with your code. To see how this could look like check out Step 1 in this tutorial.

  • fastify

    Fast and low overhead web framework, for Node.js

  • This time we will use a different i18next module, i18next-http-middleware. It can be used for all Deno web frameworks, like abc or ServestJS, but also for Node.js web frameworks, like express or Fastify.

  • Express

    Fast, unopinionated, minimalist web framework for node.

  • This time we will use a different i18next module, i18next-http-middleware. It can be used for all Deno web frameworks, like abc or ServestJS, but also for Node.js web frameworks, like express or Fastify.

  • deno

    A modern runtime for JavaScript and TypeScript.

  • // deno run --allow-net --allow-read index.js import { Application } from 'https://deno.land/x/abc/mod.ts' import { config } from "https://deno.land/x/dotenv/mod.ts" import { i18n, middleware } from './i18n.js' import { renderFile } from 'https://deno.land/x/dejs/mod.ts' const port = config.PORT || 8080 const app = new Application() app.renderer = { render(name, data) { return renderFile(`./views/${name}.html`, data) } } const handle = middleware.handle(i18n) app.use((next) => (c) => { handle(c) return next(c) } ) app.get('/', (c) => c.render('index', { t: c.request.t, i18n: c.request.i18n })) app.get('/raw', (c) => c.request.t('home.title')) app.start({ port }) console.log(i18n.t('server.started', { port })) console.log(i18n.t('server.started', { port, lng: 'de' })) console.log(i18n.t('server.started', { port, lng: 'it' }))

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts