No description
This repository has been archived on 2025-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • TypeScript 70.9%
  • JavaScript 12%
  • Vue 9.8%
  • Nix 5.1%
  • Shell 2.2%
Find a file
Admin 4ac6eebde0
Some checks failed
/ code-analysis (push) Failing after 12s
🛂 Adapt repo names
2025-03-27 10:46:34 +01:00
.forgejo/workflows 🛂 Adapt repo names 2025-03-27 10:46:34 +01:00
.husky 🔧 Update husky hooks 2024-05-16 16:41:19 +02:00
playground Export T component & remove namespace in useTranslate 2024-10-22 14:19:25 +02:00
src 🚑️ Revert usage of useTolgee 2024-10-22 14:29:22 +02:00
.editorconfig 🎉 Initial commit 2023-06-18 18:45:21 +02:00
.envrc 🧑‍💻 Use devenv 2024-10-22 14:18:33 +02:00
.gitignore 🧑‍💻 Use devenv 2024-10-22 14:18:33 +02:00
.npmrc 🛂 Adapt repo names 2025-03-27 10:46:34 +01:00
.nuxtrc 🎉 Initial commit 2023-06-18 18:45:21 +02:00
devenv.lock 🧑‍💻 Use devenv 2024-10-22 14:18:33 +02:00
devenv.nix 🧑‍💻 Use devenv 2024-10-22 14:18:33 +02:00
devenv.yaml 🧑‍💻 Use devenv 2024-10-22 14:18:33 +02:00
eslint.config.mjs 🔧 Migrate to ESLint 9.0 2024-05-16 16:39:59 +02:00
package.json 🛂 Adapt repo names 2025-03-27 10:46:34 +01:00
pnpm-lock.yaml ⬆️ Update deps 2024-11-17 18:31:54 +01:00
README.md 🛂 Adapt repo names 2025-03-27 10:46:34 +01:00
sonar-project.properties 💚 Replace drone by forgejo actions 2023-10-03 11:13:20 +02:00
tsconfig.json 🎉 Initial commit 2023-06-18 18:45:21 +02:00

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