Last active
August 29, 2015 14:06
-
-
Save twetzel/dbe80acb9ce6231a679b to your computer and use it in GitHub Desktop.
workaround to show nested translations for phraseapp on-page editor
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
.no_view_translation { | |
display: none; position: relative; | |
margin: 0; padding: 0; | |
} | |
body.tranlating_phrase .no_view_translation { | |
display: block; | |
width: auto; height: auto; | |
opacity: .5; | |
} |
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
en: | |
signup_form: | |
work_for_with: "Work %{for} %{app_name}" | |
for: "for" | |
with: "with" |
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
.. | |
<h2 class="loud"> | |
<%= t( "signup_form.work_for_with", for: "<span class='crossed' data-text='#{t("signup_form.with")}'>#{t("signup_form.for")}</span>") %> | |
<%= pt("signup_form.with") %> | |
<%= pt("signup_form.for") %> | |
</h2> | |
.. |
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
.. | |
# override default helper to get site-wide variables | |
def t(*args) | |
options = args.extract_options! | |
key = args.first | |
raw( I18n.t(key, options.merge({ app_name: CONFIG[:app_name] })) ) | |
end | |
# little helper to make nested translation editable | |
def pt(*args) | |
if !Rails.env.production? && session[:tranlating_mode] | |
options = args.extract_options! | |
key = args.first | |
content_tag :span, I18n.t(key, options.merge({ app_name: CONFIG[:app_name] })), class: "no_view_translation" | |
else | |
"" | |
end | |
end | |
.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment