Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问clear审计通过

i18n-patterns国际化模式

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

624

周安装

26

GitHub Stars

520

下载量

208
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:i18n-patterns(国际化模式)
来源仓库:https://github.com/thibautbaissac/rails_ai_agents
仓库路径:skills/i18n-patterns
安装命令:
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill i18n-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill i18n-patterns

简介

i18n-patterns 用于辅助前端页面、组件、样式和交互逻辑的开发与维护。

  • 适合生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码。
  • 使用时需结合项目现有设计系统、路由和构建方式,避免生成孤立片段。
  • 涉及页面改动时应配合本地预览和构建检查确认视觉效果。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

I18n Patterns for Rails 8

Overview

Rails I18n provides internationalization support:

  • Translation lookups
  • Locale management
  • Date/time/currency formatting
  • Pluralization rules
  • Lazy lookups in views

Quick Start

# config/application.rb
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :fr, :de]
config.i18n.fallbacks = true

Project Structure

config/locales/
├── en.yml                    # English defaults
├── fr.yml                    # French defaults
├── models/
│   ├── en.yml               # Model translations (EN)
│   └── fr.yml               # Model translations (FR)
├── views/
│   ├── en.yml               # View translations (EN)
│   └── fr.yml               # View translations (FR)
├── mailers/
│   ├── en.yml               # Mailer translations (EN)
│   └── fr.yml               # Mailer translations (FR)
└── components/
    ├── en.yml               # Component translations (EN)
    └── fr.yml               # Component translations (FR)

Locale File Organization

Organize locale files by domain: models/, views/, mailers/, components/.

  • Models: activerecord.models, activerecord.attributes, activerecord.errors
  • Views: nested under controller name and action (e.g. events.index.title)
  • Shared: common.actions, common.messages, common.date.formats
  • Components: components.<component_name>.<key>

See locale-files.md for complete YAML examples for models, views, shared keys, and components.

Usage Patterns

Key Principles

  • Use lazy lookup in views: t(".title") resolves to "events.index.title"
  • Use _html suffix for strings containing HTML markup
  • Use I18n.l (localize) for dates, times, and numbers — not I18n.t
  • Use I18n.t with full key path in models, services, and presenters
  • Pass dynamic values via interpolation: t(".greeting", name: user.name)

In Views

<h1><%= t(".title") %></h1>
<%= link_to t(".new_event"), new_event_path %>
<p><%= t(".welcome", name: current_user.name) %></p>
<p><%= t(".intro_html", link: link_to("here", help_path)) %></p>

In Controllers

redirect_to @event, notice: t(".success")

In Models/Presenters

I18n.t("activerecord.attributes.event/statuses.#{status}")
I18n.l(event_date, format: :long)

See usage-patterns.md for full examples including presenters, components, date/currency formatting, and pluralization.

Locale Switching

URL-Based Locale

# config/routes.rb
Rails.application.routes.draw do
  scope "(:locale)", locale: /en|fr|de/ do
    resources :events
  end
end

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  around_action :switch_locale

  private

  def switch_locale(&action)
    locale = params[:locale] || I18n.default_locale
    I18n.with_locale(locale, &action)
  end

  def default_url_options
    { locale: I18n.locale }
  end
end

User Preference Locale

class ApplicationController < ActionController::Base
  around_action :switch_locale

  private

  def switch_locale(&action)
    locale = current_user&.locale || extract_locale_from_header || I18n.default_locale
    I18n.with_locale(locale, &action)
  end

  def extract_locale_from_header
    request.env['HTTP_ACCEPT_LANGUAGE']&.scan(/^[a-z]{2}/)&.first
  end
end

Testing I18n

  • Raise on missing translations in spec/rails_helper.rb
  • Use i18n-tasks gem to detect missing and unused keys
  • Write view translation specs to assert rendered content

See testing.md for complete spec examples and i18n-tasks configuration.

Best Practices

DO

# Use nested structure matching view paths
en:
  events:
    index:
      title: Events
    show:
      title: Event Details

# Use interpolation for dynamic content
en:
  greeting: "Hello, %{name}!"

# Use _html suffix for HTML content
en:
  intro_html: "Welcome to <strong>our app</strong>"

DON'T

# Don't use flat keys
en:
  events_index_title: Events  # BAD

# Don't hardcode in views
<h1>Events</h1>  # BAD - use t(".title")

# Don't concatenate translations
t("hello") + " " + t("world")  # BAD

Checklist

  • Locale files organized by domain (models, views, etc.)
  • All user-facing text uses I18n
  • Lazy lookups in views (t(".key"))
  • Pluralization for countable items
  • Date/currency formatting localized
  • Locale switching implemented
  • i18n-tasks configured
  • Missing translation detection in tests
  • Fallbacks configured

References

  • locale-files.md — YAML locale file examples for models, views, shared keys, and components
  • usage-patterns.md — Usage examples in views, controllers, models, presenters, components, and formatting
  • testing.md — RSpec specs and i18n-tasks for translation coverage

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.53%
按下载量换算61

OpenCode

23.79%
按下载量换算49

Antigravity

18.04%
按下载量换算38

Codex

13.05%
按下载量换算27

Gemini CLI

6.44%
按下载量换算13

windsurf

3.18%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills