start moving from simple_form i18n to activerecord

This commit is contained in:
wvengen 2013-10-03 16:03:13 +02:00
parent 1674dcf851
commit bbcad49831
8 changed files with 81 additions and 71 deletions

View file

@ -73,6 +73,20 @@ module ApplicationHelper
link_to(text, url_for(url_options), html_options)
end
# Generates text for table heading for model attribute
# When the 'short' option is true, abbreviations will be used:
# 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'.
def heading_helper(model, attribute, options = {})
s = model.human_attribute_name(attribute)
if options[:short]
sshort = model.human_attribute_name("#{attribute}_short".to_sym, default: '')
s = raw "<acronym title='#{s}'>#{sshort}</acronym>" unless sshort.empty?
end
s
end
# Generates a link to the top of the website
def link_to_top

View file

@ -5,8 +5,8 @@
%table.table.table-striped
%thead
%tr
%th= t('simple_form.labels.article_category.name')
%th= t('simple_form.labels.article_category.description')
%th= heading_helper ArticleCategory, :article_category
%th= heading_helper ArticleCategory, :description
%th
%tbody
- @article_categories.each do |article_category|

View file

@ -6,16 +6,15 @@
%thead
%tr
%th
%th= sort_link_helper t('simple_form.labels.article.name'), "name"
%th= sort_link_helper heading_helper(Article, :name), "name"
%th
%th= sort_link_helper t('simple_form.labels.article.article_category'), "category"
%th= sort_link_helper t('simple_form.labels.article.unit'), "unit"
%th= sort_link_helper t('simple_form.labels.article.note'), "note"
%th{:style => "width: 4em;"}
%acronym{:title => t('.unit_quantity_desc')}= t '.unit_quantity_short'
%th{:style => "width: 5em;"}= t '.price_netto'
%th{:style => "width: 3.5em;"}= t 'simple_form.labels.defaults.tax'
%th{:style => "width: 4em;"}= t 'simple_form.labels.defaults.deposit'
%th= sort_link_helper heading_helper(Article, :category), "category"
%th= sort_link_helper heading_helper(Article, :unit), "unit"
%th= sort_link_helper heading_helper(Article, :note), "note"
%th{:style => "width: 4em;"}= heading_helper Article, :unit_quantity, short: true
%th{:style => "width: 5em;"}= heading_helper Article, :price
%th{:style => "width: 3.5em;"}= heading_helper Article, :tax
%th{:style => "width: 4em;"}= heading_helper Article, :deposit
%th{:style => "width: 3em;"}
%tbody#listbody

View file

@ -1,20 +1,16 @@
%table.table
%thead
%tr
%th
%acronym{:title => t('.available_desc')}= t '.available_short'
%th= t 'simple_form.labels.article.name'
%th= t 'simple_form.labels.article.unit'
%th
%acronym{:title => t('.price_desc')}= t '.price_short'
%th
%acronym{:title => t('.unit_quantity_desc')}= t '.unit_quantity_short'
%th
%acronym{:title => t('.order_number_desc')}= t '.order_number_short'
%th= t 'simple_form.labels.article.note'
%th= t 'simple_form.labels.article.article_category'
%th= t 'simple_form.labels.defaults.tax'
%th= t 'simple_form.labels.defaults.deposit'
%th= heading_helper Article, :availability, short: true
%th= heading_helper Article, :name
%th= heading_helper Article, :unit
%th= heading_helper Article, :price, short: true
%th= heading_helper Article, :unit_quantity, short: true
%th= heading_helper Article, :order_number, short: true
%th= heading_helper Article, :note
%th= heading_helper Article, :article_category
%th= heading_helper Article, :tax
%th= heading_helper Article, :deposit
%tbody
- @articles.each_with_index do |article, index|
= fields_for "articles[#{article.id || index}]", article do |form|

View file

@ -5,13 +5,13 @@
%table.table.table-striped
%thead
%tr
%th= t 'simple_form.labels.article.name'
%th= t 'simple_form.labels.article.origin'
%th= t 'simple_form.labels.article.manufacturer'
%th= t 'simple_form.labels.article.note'
%th{:style => "width:4em"}= t 'simple_form.labels.defaults.price'
%th= t 'simple_form.labels.article.unit'
%th= t 'simple_form.labels.defaults.unit_quantity'
%th= heading_helper Article, :name
%th= heading_helper Article, :origin
%th= heading_helper Article, :manufacturer
%th= heading_helper Article, :note
%th{:style => "width:4em"}= heading_helper Article, :price
%th= heading_helper Article, :unit
%th= heading_helper Article, :unit_quantity, short: true
%th
%tbody
- for article in @articles

View file

@ -24,16 +24,16 @@
%table.table
%thead
%tr
%th= t 'simple_form.labels.article.name'
%th= t 'simple_form.labels.article.note'
%th= t 'simple_form.labels.article.manufacturer'
%th= t 'simple_form.labels.article.origin'
%th= t 'simple_form.labels.article.unit'
%th= t '.unit_quantity_short'
%th= t '.price_short'
%th= t 'simple_form.labels.defaults.tax'
%th= t 'simple_form.labels.defaults.deposit'
%th= t 'simple_form.labels.article.article_category'
%th= heading_helper Article, :name
%th= heading_helper Article, :note
%th= heading_helper Article, :manufacturer
%th= heading_helper Article, :origin
%th= heading_helper Article, :unit
%th= heading_helper Article, :unit_quantity, short: true
%th= heading_helper Article, :price
%th= heading_helper Article, :tax
%th= heading_helper Article, :deposit
%th= heading_helper Article, :article_category
%tbody
- @updated_articles.each do |updated_article, attrs|
- article = Article.find(updated_article.id)

View file

@ -2,19 +2,19 @@
= t('.body').html_safe
%pre
= [t('.fields.status'),
t('simple_form.labels.defaults.order_number'),
t('simple_form.labels.article.name'),
t('simple_form.labels.article.note'),
t('simple_form.labels.article.manufacturer'),
t('simple_form.labels.article.origin'),
t('simple_form.labels.article.unit'),
t('simple_form.labels.defaults.price'),
t('simple_form.labels.defaults.tax'),
t('simple_form.labels.defaults.deposit'),
t('simple_form.labels.defaults.unit_quantity'),
Article.human_attribute_name(:order_number),
Article.human_attribute_name(:name),
Article.human_attribute_name(:note),
Article.human_attribute_name(:manufacturer),
Article.human_attribute_name(:origin),
Article.human_attribute_name(:unit),
Article.human_attribute_name(:price),
Article.human_attribute_name(:tax),
Article.human_attribute_name(:deposit),
Article.human_attribute_name(:unit_quantity),
t('.fields.season_amount'),
t('.fields.season_price'),
t('simple_form.labels.article.article_category')].join(" | ")
Article.human_attribute_name(:article_category)].join(" | ")
= form_for :articles, :url => parse_upload_supplier_articles_path(@supplier),
:html => { :multipart => true } do |f|

View file

@ -36,16 +36,27 @@ en:
activerecord:
attributes:
article:
article_category: article category
article_category: Category
availability: Is article available?
deposit: deposit
fc_price: FC price
fc_share: FC share
gross_price: gross price
price: price
availability_short: avail.
deposit: Deposit
fc_price: FoodCoop price
fc_price_short: FC price
fc_share: FoodCoop margin
fc_share_short: FC margin
gross_price: Gross price
manufacturer: Manufacturer
name: Name
note: Note
origin: Origin
price: Price
tax: VAT
unit: unit
unit_quantity: unit quantity
unit: Unit
unit_quantity: Unit quantity
unit_quantity_short: U.Q.
article_category:
description: Description
name: Name
financial_transaction:
amount: amount
note: note
@ -1559,16 +1570,6 @@ en:
required_users: How many users will be needed in total?
tax: In percentage, standard is 7,0
labels:
article:
article_category: Category
manufacturer: Manufacturer
name: Name
note: Note
origin: Origin
unit: Unit
article_category:
description: Description
name: Name
defaults:
amount: Amount
date: Date