# @aurium/i18n

> Internationalization made simple

Latest version **0.4.3** (published 2025-05-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @aurium/i18n
pnpm add @aurium/i18n
yarn add @aurium/i18n
bun add @aurium/i18n
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2025-05-07 |
| First published | 2019-11-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aurélio Heckert @ Aldak |
| Maintainers | aurium |
| Keywords | i18n, l10n, javascript |

## Links

- npm: https://www.npmjs.com/package/@aurium/i18n
- Repository: https://gitlab.com/nTopus/i18n
- Homepage: https://gitlab.com/nTopus/i18n#readme
- Issues: https://gitlab.com/nTopus/i18n/issues
- npm.io page: https://npm.io/package/@aurium/i18n

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.4.3 (latest) — 2025-05-07
- 0.4.2 — 2025-05-07
- 0.4.1 — 2022-05-22
- 0.4.0 — 2022-05-22
- 0.3.1 — 2022-05-22
- 0.3.0 — 2022-04-12
- 0.2.5 — 2022-01-13
- 0.2.4 — 2021-12-15
- 0.2.3 — 2021-12-06
- 0.2.2 — 2021-09-18
- 0.2.0 — 2021-07-22
- 0.1.4 — 2021-06-01
- 0.1.3 — 2020-08-18
- 0.1.2 — 2020-08-17
- 0.1.0 — 2020-04-16
- … 3 more at https://npm.io/package/@aurium/i18n/versions

## README

Internationalization made Simple
================================

The focus of this project is to make the i18n call to look simple, clean and obvious.

Instaling
---------

```bash
npm install @aurium/i18n
```

Usage
-----

```js
var l10nData = {
  en: {
    some_string: 'Some string.',
    has_n_aples: ['There is one apple.', 'There are {num} apples.']
  },
  pt_br: {
    some_string: 'Algum texto.',
    has_n_aples: ['Existe uma maçã.', 'Existem {num} maçãs.']
  }
}

const i18nBuilder = require('@aurium/i18n')
var i18n = i18nBuilder(l10nData, ['pt-Br', 'es'])

console.log('>> '+ i18n.some_string)
console.log('>> '+ i18n.has_n_aples.plural(5))
```

### Using with Typescript + Vue

`/src/i18n/index.ts`
```ts
import Vue from 'vue'
import i18nBuilder, { i18nProxy, LangData } from '@aurium/i18n'

const l10nData = {
  en: require('./l10n.en.js') as LangData,
  pt: require('./l10n.pt.js') as LangData
}

const i18n = i18nBuilder(l10nData)
export default i18n

// Allows Vue components to easily access localization results:
Vue.use({
  install (_Vue: typeof Vue): void {
    Object.defineProperty(_Vue.prototype, 'l10n', {
      get: () => i18n
    })
  }
})

declare module 'vue/types/vue' {
  interface Vue {
    l10n: i18nProxy;
  }
}
```

`/src/main.ts`
```ts
import Vue from 'vue'
import './i18n'
const app = new Vue({
  render: h => h(App)
}).$mount('#app')
```

`/src/components/SomeTest.ts`
```vue
<template>
  <strong>{{l10n.some_string}}</strong>
</template>

<script lang='ts'>
@Component()
export default class SomeTest extends Vue {
  ...
}
</script>
```

⚠ You must create localization files (like `/src/i18n/l10n.en.js` and `/src/i18n/l10n.pt.js`) to get it working. You may like to use the `extract-i18n-keys` command to help.

⚠ The localization file format may not fit to your code pattern. If you wont to format this files, you can tell eslint to ignore they. `.eslintrc.js`:
```js
module.exports = {
  ...,
  ignorePatterns: ['l10n.*.js'],
  rules: { ... },
  ...
}
```


Extracting i18n keys from source code
-------------------------------------

This package provides the `extract-i18n-keys` cli, that can find for keys like `i18n.some_string` and add this to l10n files. You can run this command to add each new key you just write to the l10n files, without change current ones.

`extract-i18n-keys` can write js file modules with occurrences information, or clean json files. You can also change your proxy var name from `i18n` to any other and use the `-p|--i18n-proxy-name` parameter to inform that.

For more details, read `extract-i18n-keys --help`.


Hacking and Contributing
------------------------

Please, [read the contributing page](https://gitlab.com/nTopus/i18n/blob/master/CONTRIBUTING.md).

---
_Source: https://npm.io/package/@aurium/i18n · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
