سؤال

Is there really no way to extract all i18n translation keys of an application?

views/pages/index.html.erb

<h1>Some content</h1>
<p><%= t('.some_translated_text') %></p>

views/pages/show.html.erb

<p><%= t('.some_other_stuff') %></p>

It would be great to have a tool that runs over the application and extracts all keys e.g.:

generic:
  views:
    pages:
      index:
        some_translated_text: "missing"
      show:
        some_other_stuff: "missing"

I really can't believe nobody has written such an extraction tool until now...

Thanks for your help.

Update:

I know this i18n-missing_translations but hope there is an easier way.

هل كانت مفيدة؟

المحلول

There appear to be a number of possible approaches to this.

  1. Create a script (e.g. with awk or sed) to scan your files with the regular expression in this question: Extract I18n translation keys from rails project

  2. Use a Rails plugin like the following: https://github.com/romanbsd/translate.

    You can run rake translate:missing and it will identify the missing keys.

  3. Incorporate tests for missing keys into your test suite framework, assuming your framework covers all views. See http://dev.innovationfactory.nl/2009/05/04/rails-i18n-caveats-and-tips/#translations

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top