# nuxt-gettext

> Translation module utilizing the gettext ecosystem

Latest version **0.2.2** (published 2020-07-10) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install nuxt-gettext
pnpm add nuxt-gettext
yarn add nuxt-gettext
bun add nuxt-gettext
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2020-07-10 |
| First published | 2020-02-12 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 59.8 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Lajos Bencz |
| Maintainers | lajosbencz |
| Keywords | nuxt, module, gettext |

## Links

- npm: https://www.npmjs.com/package/nuxt-gettext
- Repository: https://github.com/lajosbencz/nuxt-gettext
- Homepage: https://github.com/lajosbencz/nuxt-gettext#readme
- Issues: https://github.com/lajosbencz/nuxt-gettext/issues
- npm.io page: https://npm.io/package/nuxt-gettext

## Dependencies (5)

- [vue](https://npm.io/package/vue.md) ~2
- [uuid](https://npm.io/package/uuid.md) ^3.4.0
- [get-user-locale](https://npm.io/package/get-user-locale.md) ^1.3.0
- [cookie-universal](https://npm.io/package/cookie-universal.md) ^2.1.1
- [accept-language-parser](https://npm.io/package/accept-language-parser.md) ^1.5.0

## Recent versions

- 0.2.2 (latest) — 2020-07-10
- 0.2.1 — 2020-07-10
- 0.2.0 — 2020-07-10
- 0.1.7 — 2020-06-19
- 0.1.6 — 2020-02-13
- 0.1.4 — 2020-02-13
- 0.1.3 — 2020-02-13
- 0.1.1 — 2020-02-12

## README

# nuxt-gettext
Translation module utilizing the gettext ecosystem

### Installation

```bash
npm i -S nuxt-gettext
```

Optional package to generate pot file:

```
npm i -D vue-gettext-extract
```

### Usage

```js
export default {
    modules: [
        ['nuxt-gettext', {
            availableLanguages: {
                'en-US': 'English',
                'hu-HU': 'Magyar',
            }
        }]
    ]
}
```

```vue
<template>
  <div>
    <div class="float:right;">
      <a v-for="(label, code) in $language.available" @click="$language.current = code">
        {{ label }}
      </a>
    </div>
    <translate tag="h2" translate-plural="titles" :translate-n="1">
      title1
    </translate>
    <translate tag="h3" translate-context="ctx" translate-plural="titles" :translate-n="2">
      title2
    </translate>
    <p :title="$gettext('translation.tpl.tooltip')">
      <translate>translation.tpl.tag</translate>
      |
      {{ $gettext('translation.tpl.call') }}
      |
      {{ comProp }}
    </p>
  </div>
</template>

<script>
export default {
    computed: {
        comProp () {
            return this.$gettext('translation.tpl.computed')
        }
    }
}
</script>
```

This packages was inspired by [vue-gettext](https://github.com/Polyconseil/vue-gettext),
 so the API mostly follows that.
 
The main difference is that translation JSON files are lazy-loaded, but at the price of configurability:
Translation files __MUST__ be placed under ```~~/locale/*.json```, in the root folder.

Directives are also not supported, it's impossible (afaik) to get the text content of the node on the server.

### Todo
 * Tests
 * Integrate with vue router
 * Integrate with [vue-meta](https://github.com/nuxt/vue-meta)

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