Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loco

A JavaScript localization library, inspired by @lit/localize, but for server side rendering. And you can use the same file for both the server side and client side! 💥

The cool part of how this works is you can use a default language in your code and it will swap out different languages if the keys exist. If they don't, it will use the default so you don't have weird language keys showing up in your interface.

You can share the same language files between the backend and frontend if you like.

Install

npm install treeder/loco

Usage

import { Loco } from 'loco'
// Initialize:
let loco = new Loco()
await loco.addLocale('es', './public/i18n/locales/es.js')

// then use it anywhere:
let s = `<div>${loco.msg('Hello', {id: 'hello', locale: 'en'})}</div>`

Or you can use the default Loco instance and do the following:

import { addLocale, msg } from 'loco'

await addLocale('es', './public/i18n/locales/es.js')

// then use it anywhere:
let s = `<div>${msg('Hello', {id: 'hello', locale: 'en'})}</div>`

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages