Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactory of Hobo::Helper::Translations - the use of ht method/tag is reserved for keys starting with a model name - the first key passed to ht must be a model name, not a tableized name - added show_translation_keys config option that allows to show the used keys right in the output - added patches to I18n and TranslationHelper - use of translate helper instead I18n.t where possible
- Loading branch information
Showing
26 changed files
with
176 additions
and
199 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
hobo/lib/hobo/extensions/action_view/translation_helper.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ActionView::Helpers::TranslationHelper.module_eval do | ||
|
||
# we need to remove the <span> tag because it will mess up | ||
# the dryml tags when ht is used in some place | ||
# we redefine the method since we cannot catch the rescued exception | ||
# although the only difference is the rescue block | ||
def translate(key, options = {}) | ||
translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true)) | ||
if html_safe_translation_key?(key) && translation.respond_to?(:html_safe) | ||
translation.html_safe | ||
else | ||
translation | ||
end | ||
rescue I18n::MissingTranslationData => e | ||
keys = I18n.normalize_keys(I18n.locale, key, options[:scope]).join('.') | ||
"[MISSING: #{keys}]" | ||
end | ||
alias_method :t, :translate | ||
|
||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
I18n.module_eval do | ||
class << self | ||
|
||
def translate_with_show_keys(key, options = {}) | ||
translation = translate_without_show_keys(key, options) | ||
keys = normalize_keys(locale, key, options[:scope]).join('.') | ||
"[#{keys}]" + translation | ||
end | ||
alias_method_chain :translate, :show_keys | ||
|
||
alias_method :t_without_show_keys, :t | ||
alias_method :t, :translate_with_show_keys | ||
|
||
end | ||
end | ||
|
This file contains 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
Oops, something went wrong.