0

I am using Rails 3.2 with I18n for my translations. I offer my clients a search functionality, but in some cases what they want to search is in my translation file and not in the database.

A good example of this is Countries, where I want users to view the country names in their own language. I have an en.yml, fr.yml, gr.yml, ect, file containing all the countries available to the users and they need to be able to search it (in their current language)

Is there an easy way to do this? (The alternative is to put the countries in a table, which I'd like to avoid unless I have no other choice)

Theo Scholiadis
  • 2,316
  • 2
  • 22
  • 33
  • Your question is to broad. It does not describe what kind of database you are using and how your search works. – phoet Nov 27 '13 at 14:26
  • I would guess the database is irrelevant (it is MySQL). As for how it works, I would think that is irrelevant too. I have one search term and I'd like to know the fastest and easiest way to search through the contents of a yml translation file in a logical manner. Also, I didn't want to limit it to what I've done. If someone has a good way to do it that is different from what I've done, then I'll change my code accordingly. – Theo Scholiadis Nov 28 '13 at 14:55
  • Some people use fulltext search indexes like lucene, some people use fulltext features of dbs like in postgres. I don't think that this part is irrelevant. So from your comment, I guess that you have a pretty basic search that uses `like` queries or something like that. Well, so just put the whole stuff into the database, what is wrong with that? – phoet Nov 29 '13 at 09:31
  • @phoet ok now I see your point. Yes I am currently using LIKE. Well at the moment I have a whole bunch of translations in yml files, and since logically the names of countries are dependent on translations, I put them as yml files with a 2-letter ISO code and put the ISO code as a key to in the DB. I might just put them in the DB or just parse them using Ruby. – Theo Scholiadis Nov 29 '13 at 13:18

0 Answers0