From 78c81b194c668d4674abc40609b8f6402a0e2256 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 9 Oct 2013 23:00:07 +0200 Subject: [PATCH] i18n simple_form move of foodcoop --- app/helpers/application_helper.rb | 6 ++++-- app/views/foodcoop/users/_users.html.haml | 12 ++++++------ config/locales/de.yml | 19 +++++++++---------- config/locales/en.yml | 19 +++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c9caff30..46f5e6c9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -79,10 +79,12 @@ module ApplicationHelper # When there is a non-empty model attribute 'foo', it looks for # the model attribute translation 'foo_short' and use that as # heading, with an acronym title of 'foo'. + # Other options are passed through to I18n. def heading_helper(model, attribute, options = {}) - s = model.human_attribute_name(attribute) + i18nopts = options.select {|a| !['short'].include?(a) } + s = model.human_attribute_name(attribute, i18nopts) if options[:short] - sshort = model.human_attribute_name("#{attribute}_short".to_sym, default: '') + sshort = model.human_attribute_name("#{attribute}_short".to_sym, options.merge({defaults: ''})) s = raw "#{sshort}" unless sshort.empty? end s diff --git a/app/views/foodcoop/users/_users.html.haml b/app/views/foodcoop/users/_users.html.haml index 90b1de3a..1ecbb107 100644 --- a/app/views/foodcoop/users/_users.html.haml +++ b/app/views/foodcoop/users/_users.html.haml @@ -4,12 +4,12 @@ %table.table.table-striped %thead %tr - %th= t 'simple_form.labels.user.nick' - %th= t 'simple_form.labels.user.name' - %th= t 'simple_form.labels.user.email' - %th= t 'simple_form.labels.user.phone' - %th= t 'simple_form.labels.user.ordergroup' - %th= t 'simple_form.labels.user.workgroup', count: 3 + %th= heading_helper User, :nick + %th= heading_helper User, :name + %th= heading_helper User, :email + %th= heading_helper User, :phone + %th= heading_helper User, :ordergroup + %th= heading_helper User, :workgroup, count: 3 %tbody - for user in @users %tr diff --git a/config/locales/de.yml b/config/locales/de.yml index 802084f1..98fdcca6 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -52,8 +52,17 @@ de: stock_article: price: Nettopreis user: + email: Email first_name: Vorname + last_name: Nachname + name: Name + nick: Benutzername + ordergroup: Bestellgruppe password: Passwort + phone: Telefon + workgroup: + one: Arbeitsgruppe + other: Arbeitsgruppen errors: format: ! '%{attribute} %{message}' general: Ein Problem ist aufgetreten. @@ -1668,16 +1677,6 @@ de: required_users: Anzahl user_list: Verantwortliche workgroup: Arbeitsgruppe - user: - email: Email - last_name: Nachname - name: Name - nick: Benutzername - ordergroup: Bestellgruppe - phone: Telefon - workgroup: - one: Arbeitsgruppe - other: Arbeitsgruppen workgroup: next_weekly_tasks_number: Für wieviel Wochen im Voraus sollen Aufgaben erstellt werden? role_admin: Administration diff --git a/config/locales/en.yml b/config/locales/en.yml index 4d46865d..54581e6a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -71,8 +71,17 @@ en: user_list: Responsible user workgroup: Workgroup user: + email: Email first_name: First name + last_name: Last name + name: Name + nick: Username + ordergroup: Ordergroup password: Password + phone: Telephone + workgroup: + one: Workgroup + other: Workgroups errors: format: ! '%{attribute} %{message}' general: A problem has occured. @@ -1671,16 +1680,6 @@ en: phone: Phone phone2: Phone 2 url: Homepage - user: - email: Email - last_name: Last name - name: Name - nick: Username - ordergroup: Ordergroup - phone: Telephone - workgroup: - one: Workgroup - other: Workgroups workgroup: next_weekly_tasks_number: For how many weeks in advance would you like to define tasks? role_admin: Administration