A quick deep dive into 'rake gettext:find'
I am using Ruby Gettext to manage
translations. But today, when I ran
rake gettext:find to update my
PO files, none of them got updated.
After some digging, I noticed that Ruby Gettext defines one FileTask (a specific type of Rake task) per PO file, which delegates the work to GNU gettext.
FileTask looks at the timestamps of dependent files, and only executes the supplied block if any of the dependent files have a timestamp later than the file to update.
dependent_files = ["translations_template_file.pot"] file "file_to_update" => dependent_files do # update the file end
gettext:find was not doing anything
It turned out that gettext uses two FileTasks.
One to update the template:
files_needing_translations = ["file1.js", "file2.rb"] file "translations_template_file.pot" => files_needing_translations do # update the translations template file end
and another to update the PO file:
file "en-US/translation_file.po" => ["translations_template_file.pot"] do # update "en-US/translations.po" end
gettext:find did not do anything was because none of the
files needing translation were updated, thus no PO files were updated.
> touch one_of_the_files_that_gettext_looks_at.js > rake gettext:find