Adds Tolk gem for i18n web interface

Closes #793
This commit is contained in:
Antonio Tapiador del Dujo
2016-01-14 12:35:05 +01:00
parent 0a6639834d
commit 9610a6a933
7 changed files with 102 additions and 2 deletions

View File

@@ -53,6 +53,7 @@ gem 'pg_search'
gem 'ahoy_matey', '~> 1.2.1' gem 'ahoy_matey', '~> 1.2.1'
gem 'groupdate' # group temporary data gem 'groupdate' # group temporary data
gem 'tolk' # Web interface for translations
gem 'browser' gem 'browser'
gem 'turnout' gem 'turnout'

View File

@@ -344,6 +344,7 @@ GEM
rspec-support (~> 3.4.0) rspec-support (~> 3.4.0)
rspec-support (3.4.1) rspec-support (3.4.1)
ruby-progressbar (1.7.5) ruby-progressbar (1.7.5)
safe_yaml (1.0.4)
sass (3.4.21) sass (3.4.21)
sass-rails (5.0.4) sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
@@ -397,6 +398,9 @@ GEM
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.2) tilt (2.0.2)
tins (1.6.0) tins (1.6.0)
tolk (1.9.3)
rails (>= 4.0, < 4.3)
safe_yaml (>= 0.8.6)
turbolinks (2.5.3) turbolinks (2.5.3)
coffee-rails coffee-rails
turnout (2.2.1) turnout (2.2.1)
@@ -496,6 +500,7 @@ DEPENDENCIES
social-share-button! social-share-button!
spring spring
spring-commands-rspec spring-commands-rspec
tolk
turbolinks turbolinks
turnout turnout
uglifier (>= 1.3.0) uglifier (>= 1.3.0)

View File

@@ -0,0 +1,25 @@
# encoding: utf-8
# Tolk config file. Generated on January 14, 2016 12:09
# See github.com/tolk/tolk for more informations
Tolk.config do |config|
# If you need to add a mapping do it like this :
# May we suggest you use http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
# config.mapping['en-AU'] = 'English (Australia)'
# config.mapping['es-MX'] = 'Spanish (Mexico)'
# config.mapping['fr-ES'] = 'Frañol !'
# config.mapping['is'] = 'Icelandic'
# config.mapping['vi'] = 'Vietnamese'
# Master source of strings to be translated
config.primary_locale_name = 'en'
end
Tolk::ApplicationController.authenticator = proc {
authenticate_or_request_with_http_basic do |username, password|
username == Rails.application.secrets.translate_username &&
password == Rails.application.secrets.translate_password
end
}

View File

@@ -280,6 +280,8 @@ Rails.application.routes.draw do
mount LetterOpenerWeb::Engine, at: "/letter_opener" mount LetterOpenerWeb::Engine, at: "/letter_opener"
end end
mount Tolk::Engine => '/translate', :as => 'tolk'
# static pages # static pages
get '/blog' => redirect("http://diario.madrid.es/participa/") get '/blog' => redirect("http://diario.madrid.es/participa/")

View File

@@ -33,6 +33,9 @@ production: &production
google_oauth2_key: "" google_oauth2_key: ""
google_oauth2_secret: "" google_oauth2_secret: ""
translate_username: ""
translate_password: ""
rollbar_server_token: "" rollbar_server_token: ""
server_name: "" server_name: ""

View File

@@ -0,0 +1,38 @@
class CreateTolkTables < ActiveRecord::Migration
def self.up
create_table :tolk_locales do |t|
t.string :name
t.datetime :created_at
t.datetime :updated_at
end
add_index :tolk_locales, :name, :unique => true
create_table :tolk_phrases do |t|
t.text :key
t.datetime :created_at
t.datetime :updated_at
end
create_table :tolk_translations do |t|
t.integer :phrase_id
t.integer :locale_id
t.text :text
t.text :previous_text
t.boolean :primary_updated, :default => false
t.datetime :created_at
t.datetime :updated_at
end
add_index :tolk_translations, [:phrase_id, :locale_id], :unique => true
end
def self.down
remove_index :tolk_translations, :column => [:phrase_id, :locale_id]
remove_index :tolk_locales, :column => :name
drop_table :tolk_translations
drop_table :tolk_phrases
drop_table :tolk_locales
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160108133501) do ActiveRecord::Schema.define(version: 20160114110933) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -323,6 +323,32 @@ ActiveRecord::Schema.define(version: 20160108133501) do
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree
create_table "tolk_locales", force: :cascade do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "tolk_locales", ["name"], name: "index_tolk_locales_on_name", unique: true, using: :btree
create_table "tolk_phrases", force: :cascade do |t|
t.text "key"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tolk_translations", force: :cascade do |t|
t.integer "phrase_id"
t.integer "locale_id"
t.text "text"
t.text "previous_text"
t.boolean "primary_updated", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "tolk_translations", ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true, using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "email", default: "" t.string "email", default: ""
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", default: "", null: false