Files
sanasto-wiki/app/helpers/entries_helper.rb

32 lines
764 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module EntriesHelper
def alphabet_letters(language_code)
return ("A".."Z").to_a if language_code.blank?
case language_code.to_s
when "ru"
%w[
А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
]
when "no"
("A".."Z").to_a + %w[Æ Ø Å]
when "sv"
("A".."Z").to_a + %w[Å Ä Ö]
when "fi"
("A".."Z").to_a + %w[Å Ä Ö]
else
("A".."Z").to_a
end
end
def entry_translation_for(entry, language_code)
language_column = language_code.to_s
return unless entry.has_attribute?(language_column)
entry.public_send(language_column)
end
def format_entry_category(entry)
entry.category.to_s.tr("_", " ").capitalize
end
end