Index of every page on this site: llms.txt
All skills
onmax avatar

/yapyak

@b4e1a3f official
by Maxonmax/nuxt-skills729 stars
38
Run it yourself

yapyak, an i18n compiler with a small runtime: t() with the source string as the key, ICU plurals and selects, rich text, format.* for numbers, dates and lists, locale switching and persistence, yapyak.config.ts, translators, the yapyak CLI, and YAPnnnn diagnostics. Use when adding or editing user-facing text in a project that depends on yapyak, when setting up @yapyak/vite, @yapyak/react, @yapyak/vue, @yapyak/svelte, @yapyak/astro, @yapyak/nuxt, @yapyak/react-router, @yapyak/sveltekit or @yapyak/tanstack-start, or when a YAP diagnostic fires.

Use this Skill: https://skilld.dev/gh/onmax/nuxt-skills/yapyak

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesnuxt.md

≈855 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Nuxt

Nuxt 4.1+. Components, the binding, the switcher, and rich text are the Vue ones: vue.md. The module installs yapyak, @yapyak/vite, and @yapyak/vue as its own dependencies.

Packages

npx nuxi module add yapyak

Add a translator package separately: npm install @yapyak/anthropic.

Build config

export default defineNuxtConfig({
  modules: ['@yapyak/nuxt']
});

The install command writes this entry. The module registers the yapyak plugin, a server plugin, and the Nitro plugin.

yapyak.config.ts

The install command writes a starter at the project root when none exists:

import { defineConfig } from 'yapyak/config';
import { nuxt } from '@yapyak/nuxt/processor';

export default defineConfig({
  persistence: 'cookie',
  processors: [nuxt()],
  syncHtmlAttributes: true
});

nuxt() returns the Vue processor and the script processor, with t bound as an auto-import. nuxt({ explicitImports: true }) turns the ambient t off when another module auto-imports a t; the module throws at startup on such a collision otherwise.

Types

Add nothing: the module includes .yapyak/types.d.ts and maps the yapyak and @yapyak/vue type paths in the generated tsconfig.

Where t() works

Any .ts or .js file, plus <script> blocks and <template> expressions in .vue files. t and the RichText component are auto-imported. Every other export is an explicit import from yapyak or @yapyak/vue.

Component

<template>
  <button>{{ t('Save changes') }}</button>
</template>

Locale

<script setup lang="ts">
import { locale } from '@yapyak/vue';
import { format, locales } from 'yapyak';
</script>

<template>
  <button v-for="value in locales" :key="value" :disabled="value === locale" @click="locale = value">
    {{ format.in(value).displayName(value, 'language') }}
  </button>
</template>

A server-side switch is a server route that calls setLocale() inside the request, so the cookie is written on the response:

import { isLocale, setLocale } from 'yapyak';

export default defineEventHandler(async (event) => {
  const { locale } = await readBody<{ locale?: string }>(event);
  if (typeof locale === 'string' && isLocale(locale)) {
    setLocale(locale);
  }
  return null;
});

Text direction

With syncHtmlAttributes: true, <html lang> and <html dir> follow the active locale in server-rendered HTML and on client-side changes. textDirection from @yapyak/vue is available for other elements.

Rich text

Write it as in vue.md without the import: RichText is registered as a global component.

SSR

Register nothing: the module wraps the Nitro handler in withResponse and flushes buffered headers in a beforeResponse hook.

Fixed-locale build

export default defineNuxtConfig({
  modules: ['@yapyak/nuxt'],
  yapyak: {
    fixedLocale: process.env.YAPYAK_LOCALE
  }
});

Quirks

  • locale, textDirection, setLocale, getLocale, locales, and format are explicit imports. Only t and RichText are ambient.
  • Keep yapyak.config.ts at the project root, next to nuxt.config.ts, never under app/.
  • A file id in the locale files is the path from the project root, so app/app.vue is the key for the root component.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts10d3 checks · Risk SAFE
  • Gen Agent Trust Hub11d

    yapyak is an internationalization (i18n) toolchain for web applications that automates string extraction and translation using AI models. The primary security consideration is the potential for indirect prompt injection when translatable strings are sent to third-party AI providers for processing.

  • Socket10d

    No alerts

  • Snyk11d

    Risk: LOW · No issues

Signed by skilld at b4e1a3f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 15 hours ago.

Activeupdated 2 weeks ago
metadata
{
  "source": "https://github.com/yapyak/yapyak/tree/main/skills/yapyak"
}

README badge

README badge for onmax/nuxt-skills/yapyak