agentleFS
AlperGuvenAlperGuven/TRAE-Skills/.agents/skills/vue-i18n/SKILL.md

vue-i18n

Skill3 starsChanged 43 days agoMITView on GitHub

Implements vue-i18n v9 internationalization for Vue 3 apps with the Composition API. Use when adding or translating user-facing text, creating locale files, handling pluralization, or formatting dates and numbers per locale.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. xqgerogia/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

Files
SKILL.md

Vue i18n (vue-i18n)

Internationalization implementation for Vue 3 applications using vue-i18n.

When to Use

  • Adding new user-facing text to components
  • Creating new locale files (tr/en/ro)
  • Translating hardcoded strings
  • Working with date/number formatting
  • Changing language/locale

Project Structure

src/
├── i18n/
│   ├── i18n.js              # Main i18n configuration
│   ├── dateTimeFormats.js   # Date/time formatting per locale
│   └── numberFormats.js     # Number formatting per locale
└── locales/
    ├── tr/                  # Turkish (default)
    ├── en/                  # English
    └── ro/                  # Romanian
        ├── store/           # Store-related translations
        │   ├── shared.json
        │   └── admin/
        │       └── application.json
        ├── views/           # Page/view translations
        │   └── retailer/
        │       └── application.json
        ├── components/      # Component translations
        ├── constants/       # Constant translations
        └── shared/          # Shared/common translations

Core Concepts

1. Translation Function

<script setup>
import { useI18n } from 'vue-i18n'

const { t, locale } = useI18n()

// Simple translation
const message = t('store.shared.added', { element: t('store.application.product') })
// Output (tr): "Ürün eklendi!"
</script>

2. Template Usage

<template>
  <!-- Simple key -->
  <span>{{ t('store.shared.cancel') }}</span>

  <!-- With interpolation -->
  <span>{{ t('store.shared.added', { element: 'Ürün' }) }}</span>

  <!-- Pluralization -->
  <span>{{ t('store.shared.items_count', { count: items.length }) }}</span>
</template>

3. Script Options API

<script>
export default {
  methods: {
    submit() {
      const message = this.$t('store.shared.saved', { element: this.$t('common.product') })
    }
  }
}
</script>

Adding New Translations

Step 1: Identify the Namespace

Content TypeLocation
Store-related messageslocales/{locale}/store/
Page contentlocales/{locale}/views/
Reusable componentslocales/{locale}/components/
Shared constantslocales/{locale}/constants/
Common/sharedlocales/{locale}/shared/

Step 2: Add to All Locale Files

locales/tr/store/application.json (Turkish):

{
  "product": "Ürün",
  "add_product": "Ürün Ekle",
  "product_added": "{product} eklendi!"
}

locales/en/store/application.json (English):

{
  "product": "Product",
  "add_product": "Add Product",
  "product_added": "{product} added!"
}

locales/ro/store/application.json (Romanian):

{
  "product": "Produs",
  "add_product": "Adaugă Produs",
  "product_added": "{product} adăugat!"
}

Step 3: Use in Component

<script setup>
import { useI18n } from 'vue-i18n'

const { t } = useI18n()

const successMessage = t('store.application.product_added', {
  product: t('store.application.product')
})
</script>

Interpolation & Placeholders

Basic Interpolation

{
  "welcome": "Merhaba {name}!",
  "item_count": "{count} adet ürün"
}

HTML Interpolation (v-html)

{
  "link_text": "Detaylı bilgi için <a href='/help'>tıklayın</a>"
}
<span v-html="t('link_text')"></span>

List Interpolation

{
  "users_online": "{0} kullanıcı çevrimiçi"
}
<span>{{ t('users_online', [userCount]) }}</span>

Pluralization

JSON Format

{
  "item_count": "{n} ürün | {n} ürünler"
}

Usage

<span>{{ t('item_count', { n: items.length }, items.length) }}</span>

Named Pluralization

{
  "message": "{count} adet ürün seçildi | {count} adet ürün seçildi"
}

Date/Time Formatting

Define Format

src/i18n/dateTimeFormats.js:

export default {
  'tr-TR': {
    short: { year: 'numeric', month: 'short', day: 'numeric' },
    long: { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long', hour: 'numeric', minute: 'numeric' }
  },
  'en-US': {
    short: { year: 'numeric', month: 'short', day: 'numeric' },
    long: { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long', hour: 'numeric', minute: 'numeric' }
  }
}

Use in Component

<script setup>
import { useI18n } from 'vue-i18n'

const { d } = useI18n()

const formattedDate = d(new Date(), 'short')
const formattedDateTime = d(new Date(), 'long')
</script>

Number Formatting

Define Format

src/i18n/numberFormats.js:

export default {
  'tr-TR': {
    currency: { style: 'currency', currency: 'TRY' },
    decimal: { style: 'decimal', minimumFractionDigits: 2 }
  },
  'en-US': {
    currency: { style: 'currency', currency: 'USD' },
    decimal: { style: 'decimal', minimumFractionDigits: 2 }
  }
}

Use in Component

<script setup>
import { useI18n } from 'vue-i18n'

const { n } = useI18n()

const price = n(1000.50, 'currency')
const rate = n(0.15, 'percent')
</script>

Changing Locale

In Component

<script setup>
import { useI18n } from 'vue-i18n'

const { locale } = useI18n()

const changeLanguage = (lang) => {
  locale.value = lang
  localStorage.setItem('language', lang)
}
</script>

In Store (Pinia)

import { defineStore } from 'pinia'
import i18n from '@/i18n/i18n.js'

export const useSettingsStore = defineStore('settings', () => {
  const changeLocale = (locale) => {
    i18n.global.locale.value = locale
    localStorage.setItem('language', locale)
  }

  return { changeLocale }
})

Common Patterns

Error Messages with Interpolation

{
  "fetching_problem": "{element} çekilirken bir sorun oluştu!",
  "save_error": "{element} kaydedilirken bir sorun oluştu!",
  "delete_error": "{element} silinirken bir sorun oluştu!"
}
<script setup>
const { t } = useI18n()

try {
  await api.save()
} catch (err) {
  errorMessage.value = t('store.shared.save_error', {
    element: t('store.application.product')
  })
}
</script>

Notification Messages

{
  "added": "{element} eklendi!",
  "updated": "{element} güncellendi!",
  "deleted": "{element} silindi!"
}
<script setup>
import { useNotificationStore } from '@/stores/helpers/notification.js'
import { useI18n } from 'vue-i18n'

const notificationStore = useNotificationStore()
const { t } = useI18n()

const addProduct = async () => {
  await productStore.addProduct(data)
  notificationStore.add({
    type: 'success',
    message: t('store.shared.added', { element: t('store.application.product') })
  })
}
</script>

Best Practices

PracticeWhy
Use dot notation for keysstore.application.product not storeApplicationProduct
Use interpolation for variablesNever concatenate: "Hello " + name ❌ → "Hello {name}" ✓
Group related keysapplication.product.add, application.product.edit
Add to ALL localesAlways update tr/en/ro together
Use shared translationsCommon words in shared/ folder
Keep translations flatNested max 3 levels deep

Naming Conventions

{
  "store": {
    "shared": {
      "added": "{element} eklendi!",
      "fetching_problem": "{element} çekilirken sorun oluştu!",
      "save_error": "{element} kaydedilirken sorun oluştu!"
    },
    "application": {
      "product": "Ürün",
      "farmer": "Çiftçi",
      "add_product": "Ürün Ekle"
    }
  },
  "views": {
    "retailer": {
      "application": {
        "create": {
          "title": "Yeni Satış"
        }
      }
    }
  }
}

Vue-i18n Version Notes

This project uses vue-i18n v9 with Composition API:

// Correct (Composition API)
const { t, locale, d, n } = useI18n()

// Legacy (Options API)
this.$t('key')
this.$i18n.locale

Quick Reference

# Translation function
t('store.shared.added', { element: 'Ürün' })

# Date formatting
d(new Date(), 'short')

# Number formatting
n(1000.50, 'currency')

# Change locale
locale.value = 'en'

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.