Created
November 6, 2014 00:48
-
-
Save rochers/5d0b41cde0bb68ee47c3 to your computer and use it in GitHub Desktop.
Proposed new translation / methods for Carmen's country.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Would be a change to this file:
https://github.com/jim/carmen/blob/master/lib/carmen/country.rb
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.
Another way to write that ternary statement, but without any branching:
def articlelized_common_name
[prepended_article, common_name].compact.join(' ')
end
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
Could add this functionality to Carmen (which allows an optional
prepended_article
like "the" to be added to the translation file for a country.