@mlcs/nuxt-tolgee (1.6.2)

Published 2024-11-17 18:36:16 +01:00 by freesker in mlcsthor/nuxt-tolgee

Installation

@mlcs:registry=
npm install @mlcs/nuxt-tolgee@1.6.2
"@mlcs/nuxt-tolgee": "1.6.2"

About this package

Nuxt Tolgee

npm version Build Status Nuxt

⚠ To use this module, SSR must be disabled (ssr: false in nuxt.config.ts)

Quick Setup

  1. Log to NPM registry
npm config set @mlcs:registry https://git.deditoolbox.fr/api/packages/mlcsthor/npm/

npm config set -- '//git.deditoolbox.fr/api/packages/mlcsthor/npm/:_authToken' "[personal_access_token]"
  1. Add @mlcs/nuxt-tolgee dependency to your project
yarn add @mlcs/nuxt-tolgee
  1. Add @mlcs/nuxt-tolgee to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@mlcs/nuxt-tolgee"],
});
  1. Configure module inside nuxt.config.ts
export default defineNuxtConfig({
  tolgee: {
    // options
  },
});
  1. Wrap content in app.vue with Provider
<template>
  <TolgeeProvider>
    <template #fallback>
      <div>Loading...</div>
    </template>

    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>
  </TolgeeProvider>
</template>

<script setup lang="ts">
const { TolgeeProvider } = useTranslate()
</script>

That's it! You can now use @mlcs/nuxt-tolgee in your Nuxt app

Configuration

Name Type Default Description
url string / Your Tolgee instance url
key string / Your Tolgee apiKey
defaultLanguage string en Default language
languages string[] [] List of all available languages
hook boolean true Auto-retrieve translations from your instance on build
defaultNamespace boolean '' Default namespace used by useTranslate
namespaces boolean [] Namespaces to download from platform

Usage

<template>
  <p>{{ t('hello') }}</p>
  <!-- OR -->
  <p><T key-name="hello" /></p>

  <p>Current language: {{ language }}</p></template
>

<script setup lang="ts">
  const { t, language, T } = useTranslate()

  console.log(t("world"));
</script>

Development

# Install dependencies
yarn install

# Generate type stubs
yarn dev:prepare

# Develop with the playground
yarn dev

# Build the playground
yarn dev:build

# Run ESLint
yarn lint

# Run Vitest
yarn test
yarn test:watch

# Release new version
yarn release

Dependencies

Dependencies

ID Version
@nuxt/eslint ^0.6.0
@nuxt/kit ^3.14.159
@tolgee/format-icu ^5.31.4
@tolgee/vue ^5.31.4
defu ^6.1.4
unzipit ^1.4.3

Development dependencies

ID Version
@nuxt/eslint-config ^0.7.0
@nuxt/module-builder ^0.8.4
@nuxt/schema ^3.14.159
@nuxt/test-utils ^3.9.01
@types/node ^22.9.0
@typescript-eslint/eslint-plugin ^8.14.0
@typescript-eslint/parser ^8.14.0
eslint ^9.2.0
eslint-plugin-simple-import-sort ^12.1.0
husky ^9.0.11
lint-staged ^15.2.2
nuxt ^3.13.2
vitest ^2.1.5
Details
npm
2024-11-17 18:36:16 +01:00
46
MIT
latest
4.5 KiB
Assets (1)
Versions (5) View all
1.6.2 2024-11-17
1.6.1 2024-10-22
1.5.0 2024-05-18
1.4.2 2024-01-11
1.4.1 2024-01-11