Skip to content

Importing only specific languages

Tyler Vigario edited this page Jul 7, 2024 · 6 revisions

Description

Each language file is designed to run independently, so you can include only the language files you need.

ESM

English

import n2words from 'n2words/i18n/en.js'

n2words(100)

Arabic

import n2words from 'n2words/i18n/ar.js'

n2words(100)

English and Spanish

import n2wordsEN from 'n2words/i18n/en.js'
import n2wordsES from 'n2words/i18n/es.js'

n2wordsEN(100)
n2wordsES(100)

CommonJS

English

import('n2words/i18n/en.js').then(({ default: n2words }) => {
    n2words(100)
})

Browser

English

<script src="./en.js"></script>
<script>
    n2words(100)
</script>
Clone this wiki locally