On peut maintenant gérer les traductions dans la base, sera utilisé pour certains textes, notamment d'aide

This commit is contained in:
echarp 2014-04-04 00:51:42 +02:00
parent 26968189bf
commit 008eaeb9ef
8 changed files with 88 additions and 13 deletions

View File

@ -52,8 +52,16 @@ gem 'modernizr-rails'
gem 'activeadmin', github: 'gregbell/active_admin'
# To correct some 4.1 issue with active_admin:
gem 'polyamorous', github: 'activerecord-hackery/polyamorous'
gem "formtastic", github: "justinfrench/formtastic"
gem "ransack", github: "activerecord-hackery/ransack", branch: "rails-4.1"
gem "devise", github: "plataformatec/devise"
gem 'rails-i18n'
gem 'devise-i18n'
# Store some specific content, like application name and some important documentation
gem 'i18n-active_record',
git: 'git://github.com/svenfuchs/i18n-active_record.git',
require: 'i18n/active_record'
gem 'font-awesome-rails'
gem 'simple_calendar', github: 'echarp/simple_calendar'

View File

@ -5,6 +5,17 @@ GIT
polyamorous (0.6.4)
activerecord (>= 3.0)
GIT
remote: git://github.com/activerecord-hackery/ransack.git
revision: d51c78f9071f291b0707ed32093e191f4d8d3b26
branch: rails-4.1
specs:
ransack (1.1.0)
actionpack (>= 4.0)
activerecord (>= 4.0)
activesupport (>= 4.0)
i18n
GIT
remote: git://github.com/echarp/simple_calendar.git
revision: 415838f60847068bc29459f5a275c04d4db05ee9
@ -30,6 +41,31 @@ GIT
ransack (~> 1.0)
sass-rails
GIT
remote: git://github.com/justinfrench/formtastic.git
revision: 9904fc4336f63a5375573a7002647680dcae773e
specs:
formtastic (2.3.0.rc2)
actionpack (>= 3.0)
GIT
remote: git://github.com/plataformatec/devise.git
revision: b786c384d54a6365bdc6c0cf6068dc5325a301a9
specs:
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
GIT
remote: git://github.com/svenfuchs/i18n-active_record.git
revision: 55507cf59f8f2173d38e07e18df0e90d25b1f0f6
specs:
i18n-active_record (0.0.2)
i18n (>= 0.5.0)
GEM
remote: https://rubygems.org/
specs:
@ -89,12 +125,6 @@ GEM
compass-rails (1.1.7)
compass (>= 0.12.2)
sprockets (<= 2.11.0)
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
devise-i18n (0.10.3)
em-websocket (0.5.0)
eventmachine (>= 0.12.9)
@ -106,8 +136,6 @@ GEM
font-awesome-rails (4.0.3.1)
railties (>= 3.2, < 5.0)
formatador (0.2.4)
formtastic (2.3.0.rc2)
actionpack (>= 3.0)
fssm (0.2.10)
gritter (1.1.0)
guard (2.6.0)
@ -203,10 +231,6 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.2)
ransack (1.1.0)
actionpack (>= 3.0)
activerecord (>= 3.0)
polyamorous (~> 0.6.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
@ -261,13 +285,16 @@ DEPENDENCIES
activeadmin!
coffee-rails
compass-rails
devise!
devise-i18n
font-awesome-rails
formtastic!
gritter
guard-bundler
guard-livereload
guard-minitest
haml-rails
i18n-active_record!
jbuilder (~> 2.0)
jquery-rails
jquery-turbolinks
@ -277,6 +304,7 @@ DEPENDENCIES
quiet_assets
rails (~> 4.1.0.rc1)
rails-i18n
ransack!
redcarpet
sass-rails (~> 4.0.1)
sdoc (~> 0.4.0)

6
app/admin/translation.rb Normal file
View File

@ -0,0 +1,6 @@
ActiveAdmin.register I18n::Backend::ActiveRecord::Translation do
# See permitted parameters documentation:
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
permit_params :key, :value
end

View File

@ -0,0 +1,3 @@
require 'i18n/backend/active_record'
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)

View File

@ -26,6 +26,7 @@ fr:
city: Cité
region: Région
lug: Gull
i18n/backend/active_record/translation: Traduction
attributes:
user:
login: Login
@ -59,6 +60,12 @@ fr:
all: Toutes les régions
note:
contents: Votre commentaire
i18n/backend/active_record/translation:
locale: Langue
key: Clé
value: Valeur
interpolations: Interpolations
is_proc: Procédure?
helpers:
submit:

View File

@ -0,0 +1,11 @@
class CreateTranslation < ActiveRecord::Migration
def change
create_table :translations do |t|
t.string :locale
t.string :key
t.text :value
t.text :interpolations
t.boolean :is_proc, default: false
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20131114103121) do
ActiveRecord::Schema.define(version: 20140403204748) do
create_table "active_admin_comments", force: true do |t|
t.string "namespace"
@ -99,6 +99,14 @@ ActiveRecord::Schema.define(version: 20131114103121) do
t.string "name", default: "", null: false
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
end
create_table "users", force: true do |t|
t.string "login", default: "", null: false
t.string "password", default: "", null: false

View File

@ -5,3 +5,7 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
I18n::Backend::ActiveRecord::Translation.create([
{ locale: 'fr', key: 'layouts.application.subtitle', value: 'L\'agenda des évènements du Logiciel Libre en France' }
])