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
@rochers
Copy link
Author

rochers commented Nov 6, 2014

Could add this functionality to Carmen (which allows an optional prepended_article like "the" to be added to the translation file for a country.

@rochers
Copy link
Author

rochers commented Nov 6, 2014

@rochers
Copy link
Author

rochers commented Nov 6, 2014

Then we could add this to the us.yml file for US:

 common_name: United States
 prepended_article: the

Which would allow us to call @country.articlelized_common_name to get the right name if we desired. Same story for United Kingdom.

@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