Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link
Owner Author

commented Nov 6, 2014

@rochers

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link

commented Nov 6, 2014

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

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

This comment has been minimized.

Copy link

commented Nov 6, 2014

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
You can’t perform that action at this time.