Skip to content

Instantly share code, notes, and snippets.

@rochers
Created November 6, 2014 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rochers/5d0b41cde0bb68ee47c3 to your computer and use it in GitHub Desktop.
Save rochers/5d0b41cde0bb68ee47c3 to your computer and use it in GitHub Desktop.
Proposed new translation / methods for Carmen's country.rb
class Country
....
def prepended_article
Carmen.i18n_backend.translate(path('prepended_article'))
end
def articlelized_common_name
prepended_article.blank? common_name : "#{article} #{common_name}"
end
end
@stevenharman
Copy link

Another way to write that ternary statement, but without any branching:

def articlelized_common_name
  [prepended_article, common_name].compact.join(' ')
end

@stevenharman
Copy link

This seems like a translation (and possibly even localization) issue; articles don't necessarily work that way (and perhaps not even exist?) in other languages. i.e., this is probably not a concern Carmen should know about. You could consider wrapping Carmen with a small veneer which added this functionality. Or perhaps building a wrapper for the default backend which allowed you to add it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment