Skip to content

andreruffert/i18n-literally

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

i18n-literally

A simple way to introduce internationalization to your JS.

CI status npm version npm downloads

Install

$ npm install i18n-literally

Usage

import i18n from 'i18n-literally';
import db from './i18n.db.json';

// Set the database
i18n.db = db;

// 1. Write in the default language
i18n`Hello ${'World'}!`
// => Hello World!

// 2. Add/update your translations for a language
"$ npx i18n-literally index.js es"

// 3. Get translations based on locale
i18n.locale = 'es';
i18n`Hello ${'World'}!`
// => Hola World!

Write your entire application in the default language, and support multiple versions of the language by simply changing the i18n.locale. To Add/update translations simply run the cli.

API

i18n`template`

Returns a string based on the locale (default "en").

i18n.locale

Type: string Default: en

i18n.db

Type: object Default: {}

CLI

The cli helps you to easily maintain your translations in a simple web app. All translations are stored in a i18n.db.json file.

$ npx i18n-literally --help

  Usage:
    $ literally <cmd> <entry> <locale> [db]

  Arguments:
    <cmd>       Command defaults to "edit" (edit, check-missing-translations)
    <entry>     The entry file of your app
    <locale>    Locale to add/update translations for
    [db]        Database file defaults to "./i18n.db.json"

  Options:
    --root      Project's root directory (default: $PWD)
    --rootAlias Alias used by imports for project's root
    --help      Show information
    --version   Show current version

  Examples:
    $ literally edit ./index.js es
    $ literally edit ./src/index.js en --root=src --rootAlias=~

The cli web app to add/update translations. alt text

Related

Inspired by this post from Andrea Giammarchi.

License

MIT ยฉ Andrรฉ Ruffert

About

๐ŸŒ A simple way to introduce internationalization to your JS

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy