diff --git a/Gemfile b/Gemfile
index 88051b89..3d5b03a1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -60,3 +60,5 @@ gem 'bootstrap-social-rails', '~> 4.12'
gem 'font-awesome-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', '~> 3.4.0'
+
+gem 'http_accept_language'
diff --git a/Gemfile.lock b/Gemfile.lock
index e946530f..e133b2f5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -70,6 +70,7 @@ GEM
globalid (0.3.7)
activesupport (>= 4.1.0)
hashie (3.4.4)
+ http_accept_language (2.1.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
@@ -212,6 +213,7 @@ DEPENDENCIES
coffee-rails (~> 4.2)
dotenv-rails
font-awesome-rails
+ http_accept_language
jbuilder (~> 2.5)
jquery-datatables-rails (~> 3.4.0)
jquery-rails
diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js
index c932b10d..32a2b18f 100644
--- a/app/assets/javascripts/landing.js
+++ b/app/assets/javascripts/landing.js
@@ -84,14 +84,14 @@
info: false,
ordering: false,
language: {
- emptyTable: "Past recordings are shown here."
+ emptyTable: " "
},
columns: [
- { title: "Date Recorded", data: "start_time" },
- { title: "Presentation", data: "previews"},
- { title: "Duration", data: "duration" },
- { title: "Views", data: "playbacks" },
- { title: "Actions", data: "id" }
+ { data: "start_time" },
+ { data: "previews"},
+ { data: "duration" },
+ { data: "playbacks" },
+ { data: "id" }
],
columnDefs: [
{
@@ -186,7 +186,8 @@
data.recordings[i].duration = totalMinutes;
data.recordings[i].start_time = new Date(data.recordings[i].start_time)
- .toLocaleString([], {month: 'long', day: 'numeric', year: 'numeric', hour12: 'true', hour: '2-digit', minute: '2-digit'});
+ .toLocaleString($('html').attr('lang'),
+ {month: 'long', day: 'numeric', year: 'numeric', hour12: 'true', hour: '2-digit', minute: '2-digit'});
}
table.clear();
table.rows.add(data.recordings);
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 09aa0fe1..defaca0b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -3,6 +3,11 @@ require 'digest/sha1'
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
+ before_action :set_locale
+
+ def set_locale
+ I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
+ end
def current_user
@current_user ||= User.find_by(id: session[:user_id])
diff --git a/app/models/user.rb b/app/models/user.rb
index 0d9f7aa5..9cfb2add 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -19,14 +19,6 @@ class User < ApplicationRecord
auth_hash['info']['nickname']
end
- def ownership_name
- if username.end_with? 's'
- "#{username}'"
- else
- "#{username}'s"
- end
- end
-
def room_url
"/rooms/#{username}"
end
diff --git a/app/views/bbb/recordings.jbuilder b/app/views/bbb/recordings.jbuilder
index 384c2c29..9ad2799a 100644
--- a/app/views/bbb/recordings.jbuilder
+++ b/app/views/bbb/recordings.jbuilder
@@ -15,7 +15,7 @@ unless @response.blank?
end
json.playbacks do
json.array!(recording[:playbacks]) do |playback|
- json.type playback[:type]
+ json.type t(playback[:type]) # translates the playback type
json.url playback[:url]
json.previews do
json.array!(playback[:previews]) do |preview|
diff --git a/app/views/landing/meetings.html.erb b/app/views/landing/meetings.html.erb
index 49812b87..8e927a57 100644
--- a/app/views/landing/meetings.html.erb
+++ b/app/views/landing/meetings.html.erb
@@ -1,9 +1,9 @@
<% content_for :title do %>
- Hi Everyone
+ <%= t('hi_all') %>
- The session will be taking place using the following URL
+ <%= t('session_url_explanation') %>
<% end %>
@@ -11,7 +11,7 @@
<% content_for :footer do %>
<% end %>
@@ -20,7 +20,7 @@
- <%= render 'shared/title', title: 'Start A New Session' %>
+ <%= render 'shared/title', title: t('start_new_session') %>
<%= render layout: 'shared/center_panel' do %>
diff --git a/app/views/landing/rooms.html.erb b/app/views/landing/rooms.html.erb
index 52f6e778..83cffaaf 100644
--- a/app/views/landing/rooms.html.erb
+++ b/app/views/landing/rooms.html.erb
@@ -1,17 +1,17 @@
<% if current_user %>
- <% page_title = "Welcome, #{current_user.name.split(' ').first}" %>
+ <% page_title = t('greet_user', name: current_user.name) %>
<% else %>
- <% page_title = "Welcome to #{@user.ownership_name} Meeting Space" %>
+ <% page_title= t('greet_guest', name: @user.username) %>
<% end %>
<% content_for :title do %>
<% if current_user == @user %>
- Start a new session
+ <%= t('start_new_session') %>
<% elsif current_user && current_user != @user %>
- <%= "Join #{@user.ownership_name} session" %>
+ <%= t('join_session_user', name: @user.username) %>
<% else %>
- Join the current session
+ <%= t('join_session_guest') %>
<% end %>
<% end %>
@@ -35,8 +35,16 @@
-
Past Recordings
-
+
<%= t('past_recordings') %>
+
+
+ <%= t('date_recorded') %> |
+ <%= t('presentation') %> |
+ <%= t('duration') %> |
+ <%= t('views') %> |
+ <%= t('actions') %> |
+
+
diff --git a/app/views/landing/wait_for_moderator.html.erb b/app/views/landing/wait_for_moderator.html.erb
index b3b53c46..ab720cbb 100644
--- a/app/views/landing/wait_for_moderator.html.erb
+++ b/app/views/landing/wait_for_moderator.html.erb
@@ -1,9 +1,9 @@
<% content_for :title do %>
- Looks like you're the first one here...
+ <%= t('wait_for_mod_msg') %>
- You will automatically join when the meeting starts
+ <%= t('wait_for_mod_explanation') %>
<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 6b708afb..2475e4da 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,5 +1,5 @@
-
+
Greenlight
<%= csrf_meta_tags %>
@@ -17,22 +17,22 @@
- Copy this URL to invite others to the meeting
+ <%= t('url_copy_explanation') %>
diff --git a/config/application.rb b/config/application.rb
index 46c4accf..165d5ee4 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -12,6 +12,13 @@ module Greenlight
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
+ # i18n
+ # ensure each language has a regional fallback
+ config.i18n.available_locales = %w(en en-US)
+ config.i18n.default_locale = 'en-US'
+ config.i18n.fallbacks = {'en' => 'en-US'}
+
+ # BigBlueButton
config.bigbluebutton_endpoint = ENV['BIGBLUEBUTTON_ENDPOINT']
config.bigbluebutton_secret = ENV['BIGBLUEBUTTON_SECRET']
end
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index 0a60c18d..29574fa5 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -1,5 +1,5 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET']
provider :google_oauth2, ENV['GOOGLE_OAUTH2_ID'], ENV['GOOGLE_OAUTH2_SECRET'],
- scope: 'profile', access_type: 'online', name: 'google'
+ scope: ['profile'], access_type: 'online', name: 'google'
end
diff --git a/config/locales/en-us.yml b/config/locales/en-us.yml
new file mode 100644
index 00000000..4521c7a3
--- /dev/null
+++ b/config/locales/en-us.yml
@@ -0,0 +1,49 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en-US:
+ actions: Actions
+ are_you: Are you %{name} ?
+ date_recorded: Date Recorded
+ duration: Duration
+ enter_name: Enter your name
+ greet_user: Welcome, %{name}
+ greet_guest: Welcome to %{name} Meeting Space
+ hi_all: Hi Everyone
+ join: Join
+ join_session_guest: Join the current session
+ join_session_user: Join %{name} session
+ login: login
+ logout: logout
+ my_room: my room
+ oauth_signup: Signup for customized sessions
+ past_recordings: Past Recordings
+ powered_bigbluebutton: Powered by BigBlueButton
+ presentation: Presentation
+ refresh_html: Click refresh to generate a new meeting URL
+ session_url_explanation: The session will be taking place using the following URL
+ start: Start
+ start_new_session: Start a new session
+ url_copy_explanation: Copy this URL to invite others to the meeting
+ video: Video
+ views: Views
+ wait_for_mod_msg: Looks like you're the first one here...
+ wait_for_mod_explanation: You will automatically join when the meeting starts
diff --git a/config/locales/en.yml b/config/locales/en.yml
deleted file mode 100644
index 06539571..00000000
--- a/config/locales/en.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-# Files in the config/locales directory are used for internationalization
-# and are automatically loaded by Rails. If you want to use locales other
-# than English, add the necessary files in this directory.
-#
-# To use the locales, use `I18n.t`:
-#
-# I18n.t 'hello'
-#
-# In views, this is aliased to just `t`:
-#
-# <%= t('hello') %>
-#
-# To use a different locale, set it with `I18n.locale`:
-#
-# I18n.locale = :es
-#
-# This would use the information in config/locales/es.yml.
-#
-# To learn more, please read the Rails Internationalization guide
-# available at http://guides.rubyonrails.org/i18n.html.
-
-en:
- hello: "Hello world"