Class: Translatomatic::CLI::Database
- Defined in:
- lib/translatomatic/cli/database.rb
Overview
Database functions for the command line interface
Instance Method Summary collapse
-
#search(string, locale = nil) ⇒ void
Search database for the given string.
Instance Method Details
#search(string, locale = nil) ⇒ void
This method returns an undefined value.
Search database for the given string
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/translatomatic/cli/database.rb', line 12 def search(string, locale = nil) Translatomatic::Database.new() texts = Translatomatic::Model::Text.where('value LIKE ?', "%#{string}%") if locale db_locale = Translatomatic::Model::Locale.from_tag(locale) texts = texts.where(locale: db_locale) end texts.find_each do |text| puts "(%s) %s" % [text.locale, text.value] text.translations.each do |translation| puts " -> (%s) %s" % [translation.locale, translation.value] end puts end end |