Rails:如何生成像django这样的翻译文件

Par*_*ngh 5 django ruby-on-rails ruby-on-rails-3 rails-i18n

我试图在rails中使用国际化.在这里,我发现了这个命令

<%= t :hello_world %>
Run Code Online (Sandbox Code Playgroud)

我知道Ineed 在文件config/locales/en.yml中定义:hello_world是这样的

# config/locales/en.yml
en:
  hello_world: Hello world!
Run Code Online (Sandbox Code Playgroud)

我想知道的是在django中它使用makemessages 生成翻译文件,有没有办法在rails中做到这一点?找到和编写完整的翻译成为一项繁琐的工作.

谢谢

jhc*_*ran 2

您可以考虑检查https://github.com/svenfuchs/i18n-missing_translations,它提供了一种在您浏览应用程序时构建缺少翻译键的 yml 的方法。

如果您有详尽的覆盖范围,那么在运行测试时连接它应该会产生所有丢失的翻译。

它看起来不像 Django 的 makemessages 那么灵活,但它是一个开始。