Skip to content

Instantly share code, notes, and snippets.

@twetzel
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save twetzel/dbe80acb9ce6231a679b to your computer and use it in GitHub Desktop.

Select an option

Save twetzel/dbe80acb9ce6231a679b to your computer and use it in GitHub Desktop.

Revisions

  1. twetzel revised this gist Sep 3, 2014. 1 changed file with 0 additions and 0 deletions.
    Binary file added translation_result.jpg
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  2. twetzel revised this gist Sep 3, 2014. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions page_helper.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,13 @@
    ..

    # 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!
  3. twetzel revised this gist Sep 3, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion page.html.erb
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,5 @@
    <%= 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>
    </h2>
    ..
  4. twetzel created this gist Sep 3, 2014.
    10 changes: 10 additions & 0 deletions page.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    .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;
    }
    5 changes: 5 additions & 0 deletions page.en.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    en:
    signup_form:
    work_for_with: "Work %{for} %{app_name}"
    for: "for"
    with: "with"
    6 changes: 6 additions & 0 deletions page.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    ..
    <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>
    13 changes: 13 additions & 0 deletions page_helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ..

    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

    ..