百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

i18n_generators

> 编程语言
开源

一套 Rails 生成器 gem 插件,可为几乎所有已知的区域生成 Rails 3 和 Rails 2 I18n 本地化文件。

295 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一套 Rails 生成器 gem 插件,可为几乎所有已知的区域生成 Rails 3 和 Rails 2 I18n 本地化文件。

i18n_generators

A Rails plugin that generates the I18n locale files with automatic translation. Supporting Rails 7.0, 6.1.x, 6.0.x, 5.2.x, 5.1.x, 5.0.x, 4.2.x, 4.1.x, 4.0.x, 3.2.x, 3.1.x, 3.0.x, 2.3.x, and 2.2.x.

Here's an example of generating a translation file (the example model is taken from the Rails Girls app).

% rails g scaffold idea name description:text picture
% rails db:migrate
% rails g i18n ja

Features

This gem/plugin provides following three generator commands.

1. Generate Locale Files for ActiveRecord/ActiveSupport/ActionPack/ActionView

% rails g i18n_locale ja (de-AT, pt-BR, etc.)

Downloads the .yml file for the specified locale from the official rails-i18n repository: https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale

Then the generator sets the application default locale to the specified locale.

This will generate following locale file.

config/locales/ja.yml

2. Generate Translation YAML File For All Models/Attributes

% rails g i18n_translation ja (de-AT, pt-BR, etc.)

This will generate following YAML file.

config/locales/translation_ja.yml

The generator scans your app/models directory, and generates a YAML file with all the AR model names and attributes so that you don't have to write the YAML skeleton manually. In addition, the generator tries to translate each of them into the specified language. The generator doesn't overwrite the existing value so that you can rerun the generator again and again.

The #g mark in the generated YAML means that the line is generated by the generator.

3. Generate All

% rails g i18n ja (de-AT, pt-BR, etc.)

Executes 1 and 2 at once.

Supported versions

  • Ruby 3.1, 3.0.x, 2.7.x, 2.6.x, 2.5.x, 2.4.x, 2.3.x, 2.2.x, 2.1.x, 2.0.0, 1.9.x, 1.8.7
  • Ruby on Rails 7.0, 6.1, 6.0, 5.2, 5.1, 5.0, 4.2, 4.1, 4.0, 3.2, 3.1, 3.0
  • Ruby on Rails 2.3, 2.2 (supported by i18n_generators < 1.2)

Installation

  • Rails 3 or higher (with Bundler)

Add 'i18n_generators' to your Gemfile, then bundle. Restricting the group to :development would be a good idea, since the generator would probably be used only in development mode.

  • Rails 2

Use 'i18n_generators' version '< 1.2'.

Copyright

Copyright (c) 2008 Akira Matsuda, released under the MIT license

Issues· 9 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言