agentleFS
casooncasoon/ai-agent-config/skills/i18n/SKILL.md

i18n

Skill1 starsChanged 47 days agoMITView on GitHub

Internationalization for Astro — URL-prefix routing, per-locale t() dictionaries, language switcher, localized OG images, and hreflang. Documents the astro-v7-template default (en at root, /de/ prefix) — individual projects can and do override this, always check the project's astro.config.mjs first. Use when adding a new language, creating translated pages, fixing language switcher behavior, setting up hreflang links, or debugging locale routing. Load this skill whenever locale, language, translation, or "German" comes up in an Astro context.

47 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • volovelySkill

    pr-fix

    This skill should be used when the user asks to "fix PR comments", "address PR feedback", "resolve PR comments", provides a GitHub PR URL with intent to fix, or says "pr-fix". It reads all review comments on a PR, decides which need code fixes vs. replies, makes the fixes, and posts replies — all with explicit user approval before any GitHub action.

    Also in 3 projects that use this

  • GitHubSkill

    state-management

    CoreAI Sandbox's TanStack Query + mock-JSON data layer. USE WHEN: editing data-fetching hooks (`app/hooks/use*.ts`), adding mock data in `app/data/`, or wiring a component to query state.

    Also in 4 projects that use this

  • xfstudioSkill

    graphql

    GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.

    Also in 3 projects that use this

  • MicrosoftSkill

    bump-version

    Bump the VoxelPic version to a user-specified value. USE FOR: setting or updating the project version across all files that embed it. Applies to requests like 'bump version to X.Y.Z', 'set version', or 'update version'.

    Also in 4 projects that use this

  • +2 more from CES-Ltd

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 38 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create src/pages/<name>.astro with const locale = 'en'.

    line 131
  2. Very specific:

    Add translation keys to both en.ts and de.ts.

    line 133
  3. Very specific:

    Add nav links via localePath('/<name>', locale).

    line 134
  4. Distinctive:

    Add OG image entries for both locales in the OG generator.

    line 135
  5. Very specific:

    Add the locale to astro.config.mjs (locales: ['en', 'de', 'fr']).

    line 139
  6. Very specific:

    Create src/i18n/fr.ts and register it in src/i18n/index.ts.

    line 141
  7. Very specific:

    Create src/pages/fr/ and duplicate the localized pages with const locale = 'fr'.

    line 142
  8. Very specific:

    Update the sitemap config: locales: { en: 'en', de: 'de', fr: 'fr' }.

    line 143
  9. Distinctive:

    Add OG image entries for the new locale.

    line 144

“Common” is measured: kept by at least 6 in 10 of the 38 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

i18n

Before applying any of this: check the project's astro.config.mjs for defaultLocale/locales/prefixDefaultLocale, and check whether localePath/switchLocalePath/useTranslations are actually imported anywhere in src/pages. This skill documents the astro-v7-template default — projects frequently override the locale direction (e.g. a German-market site making de the unprefixed default), and some projects abandon the shared-dictionary pattern entirely in favor of hand-duplicated per-locale page files with hardcoded content. Don't assume either pattern without verifying against the actual project first.

Architecture (astro-v7-template default)

Two layers:

  1. Astro i18n routing — URL prefixing (/de/contact).
  2. App-level translations — t('key') per locale.

Typical locales

  • en as default without prefix — /, /contact.
  • de prefixed — /de/, /de/contact.

(Some projects flip this — de as the unprefixed default for a German-only market, en prefixed. Same mechanism, just swap which locale has the empty prefix in astro.config.mjs and langPrefixes/routeMap.)

Astro config

// astro.config.mjs
export default defineConfig({
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'de'],
    routing: {
      prefixDefaultLocale: false,  // EN at root, DE at /de/
    },
  },
});

Utilities

// Build a locale-prefixed path
localePath('/contact', 'en');  // → '/contact'
localePath('/contact', 'de');  // → '/de/contact'

// Detect locale from URL
getLocaleFromPath('/de/contact');  // → 'de'
getLocaleFromPath('/contact');     // → 'en'

// Swap locale in the current path
switchLocalePath('/de/contact', 'en');  // → '/contact'
switchLocalePath('/contact', 'de');     // → '/de/contact'

// Translation helper
const t = useTranslations(dictionary);
t('nav.home');  // → 'Home'

Translation files

src/i18n/
  en.ts       # English
  de.ts       # German
  index.ts    # t() helper wiring
// src/i18n/en.ts
export default {
  'nav.home': 'Home',
  'nav.contact': 'Contact',
  'home.title': 'My site',
  'contact.title': 'Contact',
  'contact.send': 'Send',
  '404.title': '404 — Page not found',
} as const;
// src/i18n/index.ts
import type { Locale, Translations } from '@/lib/i18n';
import { useTranslations } from '@/lib/i18n';
import de from './de.js';
import en from './en.js';

const translations: Record<Locale, Translations> = { en, de };

export function t(locale: Locale) {
  return useTranslations(translations[locale]);
}

Page pattern

Each locale gets its own page file:

src/pages/
  index.astro           # EN homepage
  contact.astro         # EN contact
  de/
    index.astro         # DE homepage
    contact.astro       # DE contact
---
import { localePath } from '@/lib/i18n';
import { t } from '@/i18n';

const locale = 'de';
const tr = t(locale);

const links = [
  { href: localePath('/', locale), label: tr('nav.home') },
  { href: localePath('/contact', locale), label: tr('nav.contact') },
];
---

<BaseLayout title={tr('home.title')} lang={locale}>
  <Navbar slot="header" links={links}>
    <a href="/contact">EN</a>
  </Navbar>
  <h1>{tr('home.title')}</h1>
</BaseLayout>

Adding a new page (both locales)

  1. Create src/pages/<name>.astro with const locale = 'en'.
  2. Create src/pages/de/<name>.astro with const locale = 'de'.
  3. Add translation keys to both en.ts and de.ts.
  4. Add nav links via localePath('/<name>', locale).
  5. Add OG image entries for both locales in the OG generator.

Adding a new locale

  1. Add the locale to astro.config.mjs (locales: ['en', 'de', 'fr']).
  2. Extend your Locale type (['en', 'de', 'fr'] as const).
  3. Create src/i18n/fr.ts and register it in src/i18n/index.ts.
  4. Create src/pages/fr/ and duplicate the localized pages with const locale = 'fr'.
  5. Update the sitemap config: locales: { en: 'en', de: 'de', fr: 'fr' }.
  6. Add OG image entries for the new locale.

Sitemap and hreflang

sitemap({
  i18n: {
    defaultLocale: 'en',
    locales: { en: 'en', de: 'de' },
  },
}),

The integration emits <xhtml:link rel="alternate" hreflang="…"> for each localized URL automatically.

Language switcher pattern

<!-- On EN pages: link to DE version -->
<a href="/de/contact" class="text-xs font-medium no-underline">DE</a>

<!-- On DE pages: link to EN version -->
<a href="/contact" class="text-xs font-medium no-underline">EN</a>

Build the href with switchLocalePath(Astro.url.pathname, otherLocale) if you want a switcher that works on any page.

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.