Using get text in gem and code

115 views
Skip to first unread message

Martin Streicher

unread,
Oct 16, 2014, 2:51:13 PM10/16/14
to rails...@googlegroups.com
I recently converted a large Rails 3 application into a gem. Localization is part of the original code base. 

I modified the gettext:find  task to look in the gem and in any app that uses the gem to find potential translations.

namespace :gettext do
 
def files_to_translate
    files_in_application
+ files_in_gem
 
end


 
def files_in_application
   
Dir.glob(glob_pattern)
 
end


 
def files_in_gem
   
Dir.glob(File.join(MyGem.root, glob_pattern))
 
end


 
def glob_pattern
   
"{app,lib,config,locale}/**/*.{rb,erb,haml,slim,rhtml}"
 
end
end

Hence, the task looks in the gem root and, as before, Rails.root for files to translate. 

My question: Is there a way to find .po files in both places? I am OK with .mo files being stored in Rails.root/locales. (The .mo files can then be checked into the repo for the app without affecting the gem repo.) But I would like a way for the .po files of the gem to override any .po files in the app. 

Any ideas? 

Martin





Reply all
Reply to author
Forward
0 new messages