# Using get text in gem and code

**URL:** <https://www.ruby-forum.com/t/using-get-text-in-gem-and-code/232589>\
**Category:** Rails I18n\
**Created:** [October 16, 2014, 9:25pm UTC](https://www.ruby-forum.com/t/using-get-text-in-gem-and-code/232589 "2014-10-16T21:25:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 16, 2014, 9:25pm UTC](https://www.ruby-forum.com/t/using-get-text-in-gem-and-code/232589/1 "2014-10-16T21:25:27Z")

</div>

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
