summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock10
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/profiles_controller.rb4
-rw-r--r--app/views/profiles/show.html.haml4
-rw-r--r--config/initializers/fast_gettext.rb3
-rw-r--r--db/migrate/20170413035209_add_preferred_language_to_users.rb14
-rw-r--r--db/schema.rb3
-rw-r--r--lib/gitlab/i18n.rb9
-rw-r--r--locale/de/gitlab.po27
-rw-r--r--locale/de/gitlab.po.time_stamp0
-rw-r--r--locale/en/gitlab.po27
-rw-r--r--locale/en/gitlab.po.time_stamp0
-rw-r--r--locale/es/gitlab.po27
-rw-r--r--locale/es/gitlab.po.time_stamp0
-rw-r--r--locale/gitlab.pot28
17 files changed, 167 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 51b4d06b01b..40948f2e89c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
*.log
*.swp
+*.mo
+*.edit.po
.DS_Store
.bundle
.chef
@@ -53,3 +55,4 @@ eslint-report.html
/shared/*
/.gitlab_workhorse_secret
/webpack-report/
+/locale/**/LC_MESSAGES
diff --git a/Gemfile b/Gemfile
index ad8db206da6..6c1f6346071 100644
--- a/Gemfile
+++ b/Gemfile
@@ -254,6 +254,10 @@ gem 'sentry-raven', '~> 2.4.0'
gem 'premailer-rails', '~> 1.9.0'
+# I18n
+gem 'gettext_i18n_rails', '~> 1.8.0'
+gem 'gettext', '~> 3.2.2', require: false, group: :development
+
# Metrics
group :metrics do
gem 'allocations', '~> 1.0', require: false, platform: :mri
diff --git a/Gemfile.lock b/Gemfile.lock
index bb91db1e805..ca4084e18a2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -200,6 +200,7 @@ GEM
faraday_middleware-multi_json (0.0.6)
faraday_middleware
multi_json
+ fast_gettext (1.4.0)
ffaker (2.4.0)
ffi (1.9.10)
flay (2.8.1)
@@ -253,6 +254,11 @@ GEM
gemojione (3.0.1)
json
get_process_mem (0.2.0)
+ gettext (3.2.2)
+ locale (>= 2.0.5)
+ text (>= 1.3.0)
+ gettext_i18n_rails (1.8.0)
+ fast_gettext (>= 0.9.0)
gherkin-ruby (0.3.2)
gitaly (0.5.0)
google-protobuf (~> 3.1)
@@ -424,6 +430,7 @@ GEM
licensee (8.7.0)
rugged (~> 0.24)
little-plugger (1.1.4)
+ locale (2.1.2)
logging (2.1.0)
little-plugger (~> 1.1)
multi_json (~> 1.10)
@@ -778,6 +785,7 @@ GEM
temple (0.7.7)
test_after_commit (1.1.0)
activerecord (>= 3.2)
+ text (1.3.1)
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
@@ -904,6 +912,8 @@ DEPENDENCIES
fuubar (~> 2.0.0)
gemnasium-gitlab-service (~> 0.2)
gemojione (~> 3.0)
+ gettext (~> 3.2.2)
+ gettext_i18n_rails (~> 1.8.0)
gitaly (~> 0.5.0)
github-linguist (~> 4.7.0)
gitlab-flowdock-git-hook (~> 1.0.1)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e77094fe2a8..5a3bd4040cc 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -265,4 +265,10 @@ class ApplicationController < ActionController::Base
def u2f_app_id
request.base_url
end
+
+ def set_locale
+ requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
+ locale = FastGettext.set_locale(requested_locale)
+ I18n.locale = locale
+ end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 987b95e89b9..0f01bf7e706 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -3,6 +3,7 @@ class ProfilesController < Profiles::ApplicationController
before_action :user
before_action :authorize_change_username!, only: :update_username
+ before_action :set_locale, only: :show
skip_before_action :require_email, only: [:show, :update]
def show
@@ -85,7 +86,8 @@ class ProfilesController < Profiles::ApplicationController
:twitter,
:username,
:website_url,
- :organization
+ :organization,
+ :preferred_language
)
end
end
diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml
index c74b3249a13..d8ef64ceb72 100644
--- a/app/views/profiles/show.html.haml
+++ b/app/views/profiles/show.html.haml
@@ -73,6 +73,10 @@
= f.select :public_email, options_for_select(@user.all_emails, selected: @user.public_email), { include_blank: 'Do not show on profile' }, class: "select2"
%span.help-block This email will be displayed on your public profile.
.form-group
+ = f.label :preferred_language, class: "label-light"
+ = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |lang| [_(lang[0]), lang[1]] },
+ {}, class: "select2"
+ .form-group
= f.label :skype, class: "label-light"
= f.text_field :skype, class: "form-control"
.form-group
diff --git a/config/initializers/fast_gettext.rb b/config/initializers/fast_gettext.rb
new file mode 100644
index 00000000000..cfc3427b5ae
--- /dev/null
+++ b/config/initializers/fast_gettext.rb
@@ -0,0 +1,3 @@
+FastGettext.add_text_domain 'gitlab', path: 'locale', type: :po
+FastGettext.default_available_locales = ['en', 'es','de']
+FastGettext.default_text_domain = 'gitlab'
diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb
new file mode 100644
index 00000000000..5dc128dbaea
--- /dev/null
+++ b/db/migrate/20170413035209_add_preferred_language_to_users.rb
@@ -0,0 +1,14 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddPreferredLanguageToUsers < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def change
+ add_column_with_default :users, :preferred_language, :string, default: 'en'
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5689f7331dc..03ce1257088 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: 20170408033905) do
+ActiveRecord::Schema.define(version: 20170413035209) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -1304,6 +1304,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do
t.boolean "notified_of_own_activity"
t.boolean "require_two_factor_authentication_from_group", default: false, null: false
t.integer "two_factor_grace_period", default: 48, null: false
+ t.string "preferred_language"
end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb
new file mode 100644
index 00000000000..85e527afd71
--- /dev/null
+++ b/lib/gitlab/i18n.rb
@@ -0,0 +1,9 @@
+module Gitlab
+ module I18n
+ AVAILABLE_LANGUAGES = [
+ ['English', 'en'],
+ ['Spanish', 'es'],
+ ['Deutsch', 'de']
+ ]
+ end
+end
diff --git a/locale/de/gitlab.po b/locale/de/gitlab.po
new file mode 100644
index 00000000000..7f32771b80f
--- /dev/null
+++ b/locale/de/gitlab.po
@@ -0,0 +1,27 @@
+# German translations for gitlab package.
+# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the gitlab package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gitlab 1.0.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: 2017-04-12 22:37-0500\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"\n"
+
+msgid "Deutsch"
+msgstr ""
+
+msgid "English"
+msgstr ""
+
+msgid "Spanish"
+msgstr ""
diff --git a/locale/de/gitlab.po.time_stamp b/locale/de/gitlab.po.time_stamp
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/locale/de/gitlab.po.time_stamp
diff --git a/locale/en/gitlab.po b/locale/en/gitlab.po
new file mode 100644
index 00000000000..f93f438b424
--- /dev/null
+++ b/locale/en/gitlab.po
@@ -0,0 +1,27 @@
+# English translations for gitlab package.
+# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the gitlab package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gitlab 1.0.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: 2017-04-12 22:36-0500\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: English\n"
+"Language: en\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"\n"
+
+msgid "Deutsch"
+msgstr ""
+
+msgid "English"
+msgstr ""
+
+msgid "Spanish"
+msgstr ""
diff --git a/locale/en/gitlab.po.time_stamp b/locale/en/gitlab.po.time_stamp
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/locale/en/gitlab.po.time_stamp
diff --git a/locale/es/gitlab.po b/locale/es/gitlab.po
new file mode 100644
index 00000000000..e2d03d88347
--- /dev/null
+++ b/locale/es/gitlab.po
@@ -0,0 +1,27 @@
+# Spanish translations for gitlab package.
+# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the gitlab package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gitlab 1.0.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: 2017-04-13 00:07-0500\n"
+"Language-Team: Spanish\n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"Last-Translator: \n"
+"X-Generator: Poedit 2.0.1\n"
+
+msgid "Deutsch"
+msgstr "Alemán"
+
+msgid "English"
+msgstr "Inglés"
+
+msgid "Spanish"
+msgstr "Español"
diff --git a/locale/es/gitlab.po.time_stamp b/locale/es/gitlab.po.time_stamp
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/locale/es/gitlab.po.time_stamp
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
new file mode 100644
index 00000000000..a90fc69d94b
--- /dev/null
+++ b/locale/gitlab.pot
@@ -0,0 +1,28 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the gitlab package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: gitlab 1.0.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-04-13 00:01-0500\n"
+"PO-Revision-Date: 2017-04-13 00:01-0500\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+msgid "Deutsch"
+msgstr ""
+
+msgid "English"
+msgstr ""
+
+msgid "Spanish"
+msgstr ""