DeployStack Docs

Internationalization (i18n)

DeployStack uses Vue I18n with a modular file structure. Translations are organized by feature for easy maintenance.

Architecture

  • Location: src/i18n/
  • Current language: English only (en)
  • Structure: Feature-based translation files
  • Framework: Vue I18n with Composition API (non-legacy mode)

Basic Usage

Using in Components

<script setup lang="ts">
import { useI18n } from 'vue-i18n'

const { t } = useI18n()

// Use in script
const message = t('globalSettings.errors.configNotSet')
</script>

<template>
  <!-- Use in template -->
  <h1>{{ $t('globalSettings.title') }}</h1>
  <button>{{ $t('buttons.save') }}</button>
</template>

Adding New Translations

1. Add to Translation File

Find the appropriate file in src/i18n/locales/en/ and add your translation:

// Example: Adding to globalSettings.ts
export default {
  errors: {
    configNotSet: 'Configuration not set',
    fetchFailed: 'Failed to fetch settings',
    // Add your new translation here
    myNewError: 'Something went wrong with {item}'
  }
}

2. Use in Component

<script setup lang="ts">
import { useI18n } from 'vue-i18n'
const { t } = useI18n()

// With parameters
const errorMsg = t('globalSettings.errors.myNewError', { item: 'deployment' })
</script>

Creating a New Feature Translation File

When adding a new feature, create a dedicated translation file:

1. Create the Translation File

// src/i18n/locales/en/myFeature.ts
export default {
  title: 'My Feature',
  description: 'Feature description',
  actions: {
    submit: 'Submit',
    cancel: 'Cancel'
  },
  messages: {
    success: 'Operation successful',
    error: 'An error occurred: {message}'
  }
}

2. Register in Index

// src/i18n/locales/en/index.ts
import myFeatureMessages from './myFeature'

export default {
  // ... existing imports
  myFeature: myFeatureMessages
}

Key Naming Convention

Structure

{feature}.{section}.{key}

Examples:

  • globalSettings.errors.configNotSet
  • mcpCatalog.filters.byCategory
  • common.buttons.save
  • validation.required

Rules

  1. Use camelCase for keys
  2. Group by feature (globalSettings, mcpCatalog, teams)
  3. Use descriptive names (avoid generic keys like 'msg1', 'error1')
  4. Common translations go in common.ts
  5. Validation messages can be shared or feature-specific

Parameters and Pluralization

Parameters

// Translation
messages: {
  deploymentFailed: 'Deployment failed: {error}',
  userGreeting: 'Welcome back, {userName}!'
}

// Usage
t('messages.deploymentFailed', { error: 'Invalid credentials' })
t('messages.userGreeting', { userName: user.name })

Pluralization

// Translation
messages: {
  itemCount: '{count} {count, plural, one {item} other {items}}'
}

// Usage
t('messages.itemCount', { count: 1 }) // "1 item"
t('messages.itemCount', { count: 5 }) // "5 items"

Quick Reference

Common Translation Keys

CategoryKey ExampleLocation
Buttonsbuttons.save, buttons.cancelcommon.ts
Validationvalidation.required, validation.emailcommon.ts
Statuscommon.status.runningcommon.ts
Errors{feature}.errors.{errorType}Feature file
Success{feature}.messages.successFeature file
Forms{feature}.form.{field}.labelFeature file