i18n-checker
This gem provides a Rake task to check translation file mistakes and translated text references from template files etc.
Current version supports Ruby source code, Haml template file.
- Ruby source
- Haml template
Basic usage
Detected out of reference text, Delete unused translation text at once.
Add the following tasks to your Rakefile.
require 'i18n_checker/rake_task'
I18nChecker::RakeTask::ReferenceCheck.new do |task|
task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
task.locale_file_paths = FileList['config/locales/*'] # locale file paths
end
I18nChecker::RakeTask::UnusedCheck do |task|
task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
task.locale_file_paths = FileList['config/locales/*'] # locale file paths
end
After that we just execute the task.
bundle exec rake locale_reference_check
bundle exec rake locale_unused_check
Check translation of translated text
Detect translated text references that are broken.
It is useful for detecting text that is not in the translation file of a particular language.
require 'i18n_checker/rake_task'
I18nChecker::RakeTask::ReferenceCheck.new do |task|
task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
task.locale_file_paths = FileList['config/locales/*'] # locale file paths
end
After that we just execute the task.
bundle exec rake locale_reference_check
Delete unused translated text
Using the locale_clean task you can delete unused translated text from the file.
Since you can delete translated text that you do not use safely, you can reduce the maintenance cost by running it periodically.
require 'i18n_checker/rake_task'
I18nChecker::RakeTask::UnusedClean do |task|
task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
task.locale_file_paths = FileList['config/locales/*'] # locale file paths
end
After that we just execute the task.
bundle exec rake locale_unused_clean
Run the test
bundle install
bundle exec rake spec