Skip to content

Instantly share code, notes, and snippets.

@twetzel
Last active August 29, 2015 14:06
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 twetzel/dbe80acb9ce6231a679b to your computer and use it in GitHub Desktop.
Save twetzel/dbe80acb9ce6231a679b to your computer and use it in GitHub Desktop.
workaround to show nested translations for phraseapp on-page editor
.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;
}
en:
signup_form:
work_for_with: "Work %{for} %{app_name}"
for: "for"
with: "with"
..
<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>
..
..
# 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