Skip to content

A Ruby script that helps you internationalize your Rails app! This script reads html.erb files and outputs the hard-coded text in en.yml-friendly format.

Notifications You must be signed in to change notification settings

Hammadk/rails_auto_i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

I18n helper for Rails

A Ruby script that helps you internationalize your Rails app! This script reads html.erb files and outputs the hard-coded text in an en.yml-friendly format.

Its reads through all of the given html.erb files, parses them and finds all of the nodes with hard-coded text.

Usage:

git clone git@github.com:Hammadk/rails_auto_i18n.git
gem install nokogiri

ruby rails_auto_i18n/lib/auto_i18n.rb <directory_with_html_erb_files>

External Dependencies:

TODO

  1. Implement the --tag option, that outputs the rails translate method after the yml text output.
  2. Implement the --replace option, that replaces the hard-coded text in your view files with the i18n tag in a translate method. I.e. <% t(".unique_tag") %>
  3. Write tests (Currently only tested on dummy app)

Known Limitations:

  • The extraction of text isn't perfect, and requires someone to examine the output for oddities.
  • The unique identifiers are unique, but they are not the very readable. Ideally, someone should go over them and replace them with human-readable identifiers.

About

A Ruby script that helps you internationalize your Rails app! This script reads html.erb files and outputs the hard-coded text in en.yml-friendly format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages