aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock3
-rw-r--r--app/helpers/pagination_helper.rb4
-rw-r--r--config/initializers/locale.rb13
-rw-r--r--config/locales/networks.fr.yml4
-rw-r--r--config/locales/will_paginate.en.yml26
-rw-r--r--config/locales/will_paginate.fr.yml26
-rw-r--r--db/migrate/20170214172517_create_translations.rb17
-rw-r--r--db/schema.rb12
9 files changed, 93 insertions, 13 deletions
diff --git a/Gemfile b/Gemfile
index 8e7968be3..306689e6c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.1.10'
+gem 'i18n-active_record', :require => 'i18n/active_record'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
diff --git a/Gemfile.lock b/Gemfile.lock
index 3a6068410..f152ffd08 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -253,6 +253,8 @@ GEM
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.7.0)
+ i18n-active_record (0.1.2)
+ i18n (>= 0.5.0)
i18n-tasks (0.8.6)
activesupport
easy_translate (>= 0.5.0)
@@ -628,6 +630,7 @@ DEPENDENCIES
guard
guard-rspec
has_array_of!
+ i18n-active_record
i18n-tasks
inherited_resources
jbuilder (~> 2.0)
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
index ea5902d63..350d796ea 100644
--- a/app/helpers/pagination_helper.rb
+++ b/app/helpers/pagination_helper.rb
@@ -20,8 +20,8 @@ module PaginationHelper
end
def new_pagination collection, cls = nil
- k = collection.first.class.name.split('::').last.downcase
- pinfos = page_entries_info collection, model: t("will_paginate.page_entries_info.#{k}"), html: false
+ k = collection.first.class
+ pinfos = page_entries_info collection, model: k, html: false
if collection.total_pages > 1
links = content_tag :div, '', class: 'page_links' do
diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb
new file mode 100644
index 000000000..c7262b8a0
--- /dev/null
+++ b/config/initializers/locale.rb
@@ -0,0 +1,13 @@
+require 'i18n/backend/active_record'
+Translation = I18n::Backend::ActiveRecord::Translation
+
+if Translation.table_exists?
+ I18n.backend = I18n::Backend::ActiveRecord.new
+
+ I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
+ I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
+ I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
+ I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
+
+ I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
+end
diff --git a/config/locales/networks.fr.yml b/config/locales/networks.fr.yml
index bc9db32d9..515d4c3d1 100644
--- a/config/locales/networks.fr.yml
+++ b/config/locales/networks.fr.yml
@@ -20,8 +20,8 @@ fr:
activerecord:
models:
network:
- zero: "réseau"
- one: "réseau"
+ zero: "réseaux"
+ one: "réseau"
other: "réseaux"
attributes:
network:
diff --git a/config/locales/will_paginate.en.yml b/config/locales/will_paginate.en.yml
index f47c63986..29b8fe2bf 100644
--- a/config/locales/will_paginate.en.yml
+++ b/config/locales/will_paginate.en.yml
@@ -4,6 +4,28 @@ en:
next_label: "Next →"
page_gap: "…"
+ models:
+ referential:
+ zero: 'data spaces'
+ one: 'data space'
+ few: 'data spaces'
+ other: 'data spaces'
+ line:
+ zero: 'lines'
+ one: 'line'
+ few: 'lines'
+ other: 'lines'
+ route:
+ zero: 'routes'
+ one: 'route'
+ few: 'routes'
+ other: 'routes'
+ network:
+ zero: 'networks'
+ one: 'network'
+ few: 'networks'
+ other: 'networks'
+
page_entries_info:
search: "Results :"
list: "Paginated list"
@@ -18,7 +40,3 @@ en:
multi_page: "%{model} %{from} to %{to} of %{count}"
multi_page_html: "%{model} %{from} to %{to} of %{count}"
-
- referential: 'data space'
- line: 'line'
- route: 'route'
diff --git a/config/locales/will_paginate.fr.yml b/config/locales/will_paginate.fr.yml
index b23f5da7c..e1af0723b 100644
--- a/config/locales/will_paginate.fr.yml
+++ b/config/locales/will_paginate.fr.yml
@@ -4,6 +4,28 @@ fr:
next_label: "Suivant →"
page_gap: "…"
+ models:
+ referential:
+ zero: 'jeux de données'
+ one: 'jeu de données'
+ few: 'jeux de données'
+ other: 'jeux de données'
+ line:
+ zero: 'lignes'
+ one: 'ligne'
+ few: 'lignes'
+ other: 'lignes'
+ route:
+ zero: 'itinéraires'
+ one: 'itinéraire'
+ few: 'itinéraires'
+ other: 'itinéraires'
+ network:
+ zero: 'réseaux'
+ one: 'réseau'
+ few: 'réseaux'
+ other: 'réseaux'
+
page_entries_info:
search: "Résultats :"
list: "Liste paginée"
@@ -18,7 +40,3 @@ fr:
multi_page: "Liste des %{model} %{from} à %{to} sur %{count}"
multi_page_html: "Liste des %{model} %{from} à %{to} sur %{count}"
-
- referential: 'jeu(x) de données'
- line: 'ligne'
- route: 'itinéraire'
diff --git a/db/migrate/20170214172517_create_translations.rb b/db/migrate/20170214172517_create_translations.rb
new file mode 100644
index 000000000..689a9130a
--- /dev/null
+++ b/db/migrate/20170214172517_create_translations.rb
@@ -0,0 +1,17 @@
+class CreateTranslations < ActiveRecord::Migration
+ def self.up
+ create_table :translations do |t|
+ t.string :locale
+ t.string :key
+ t.text :value
+ t.text :interpolations
+ t.boolean :is_proc, :default => false
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :translations
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f6327e3b7..00f4aa68c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170213135212) do
+ActiveRecord::Schema.define(version: 20170214172517) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -701,6 +701,16 @@ ActiveRecord::Schema.define(version: 20170213135212) do
t.datetime "updated_at"
end
+ create_table "translations", force: true do |t|
+ t.string "locale"
+ t.string "key"
+ t.text "value"
+ t.text "interpolations"
+ t.boolean "is_proc", default: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "users", force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: ""