diff --git a/app-loader/app-loader.coffee b/app-loader/app-loader.coffee index e216a9f0..fba45384 100644 --- a/app-loader/app-loader.coffee +++ b/app-loader/app-loader.coffee @@ -3,6 +3,7 @@ window.taigaConfig = { "api": "http://localhost:8000/api/v1/", "eventsUrl": null, "debug": true, + "defaultLanguage": "en", "publicRegisterEnabled": true, "feedbackEnabled": true, "privacyPolicyUrl": null, diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index a0140849..feaffb05 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -241,7 +241,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven suffix: '.json' }) - $translateProvider.preferredLanguage('en') + $translateProvider.preferredLanguage(window.taigaConfig.defaultLanguage || 'en') init = ($log, $config, $rootscope, $auth, $events, $analytics, $translate) -> $log.debug("Initialize application") diff --git a/app/coffee/modules/resources.coffee b/app/coffee/modules/resources.coffee index 2364baa3..4c78686a 100644 --- a/app/coffee/modules/resources.coffee +++ b/app/coffee/modules/resources.coffee @@ -123,6 +123,9 @@ urls = { "userstories-csv": "/userstories/csv?uuid=%s" "tasks-csv": "/tasks/csv?uuid=%s" "issues-csv": "/issues/csv?uuid=%s" + + # locales + "locales": "/locales" } # Initialize api urls service @@ -168,5 +171,6 @@ module.run([ "$tgModulesResourcesProvider", "$tgWebhooksResourcesProvider", "$tgWebhookLogsResourcesProvider", + "$tgLocalesResourcesProvider", initResources ]) diff --git a/app/coffee/modules/resources/locales.coffee b/app/coffee/modules/resources/locales.coffee new file mode 100644 index 00000000..2c2fd170 --- /dev/null +++ b/app/coffee/modules/resources/locales.coffee @@ -0,0 +1,38 @@ +### +# Copyright (C) 2015 Andrey Antukh +# Copyright (C) 2015 Jesús Espino Garcia +# Copyright (C) 2015 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/resources/locales.coffee +### + + +taiga = @.taiga +sizeFormat = @.taiga.sizeFormat + + +resourceProvider = ($repo) -> + service = { + list: -> return $repo.queryMany("locales") + } + + return (instance) -> + instance.locales = service + + +module = angular.module("taigaResources") +module.factory("$tgLocalesResourcesProvider", ["$tgRepo", resourceProvider]) + diff --git a/app/coffee/modules/user-settings/main.coffee b/app/coffee/modules/user-settings/main.coffee index 654aee69..e3fae917 100644 --- a/app/coffee/modules/user-settings/main.coffee +++ b/app/coffee/modules/user-settings/main.coffee @@ -66,12 +66,18 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.$emit('project:loaded', project) return project + loadLocales: -> + return @rs.locales.list().then (locales) => + @scope.locales = locales + return locales + loadInitialData: -> promise = @repo.resolve({pslug: @params.pslug}).then (data) => @scope.projectId = data.project return data - return promise.then(=> @.loadProject()) + return @q.all([promise.then(=> @.loadProject()), + @.loadLocales()]) openDeleteLightbox: -> @rootscope.$broadcast("deletelightbox:new", @scope.user) diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index 6d3a9f3e..60a8c782 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -841,7 +841,8 @@ "PLACEHOLDER_FULL_NAME": "Set your full name (ex. Íñigo Montoya)", "BIO": "Bio", "PLACEHOLDER_BIO": "Tell us something about you", - "LANGUAGE": "Language" + "LANGUAGE": "Language", + "LANGUAGE_DEFAULT": "-- use default language --" } }, "WIZARD": { @@ -865,8 +866,5 @@ "LAST_EDIT": "last
edit", "LAST_MODIFICATION": "last modification" } - }, - "LANGUAGES": { - "ENGLISH": "English" } } diff --git a/app/partials/user/user-profile.jade b/app/partials/user/user-profile.jade index 45c6ee63..4f64352f 100644 --- a/app/partials/user/user-profile.jade +++ b/app/partials/user/user-profile.jade @@ -47,8 +47,8 @@ div.wrapper(tg-user-profile, ng-controller="UserSettingsController as ctrl", fieldset label(for="full-name", translate="USER_PROFILE.FIELD.LANGUAGE") - select(data-required="true", ng-model="lang") - option(value="en", translate="LANGUAGES.ENGLISH") + select(ng-model="lang", ng-options="locale.code as locale.name for locale in locales") + option(value="", translate="USER_PROFILE.FIELD.LANGUAGE_DEFAULT") fieldset label(for="bio", translate="USER_PROFILE.FIELD.BIO") diff --git a/conf/conf.example.json b/conf/conf.example.json index f378107e..2a78a5ea 100644 --- a/conf/conf.example.json +++ b/conf/conf.example.json @@ -2,11 +2,12 @@ "api": "http://localhost:8000/api/v1/", "eventsUrl": null, "debug": true, + "debugInfo": false, + "defaultLanguage": "en", "publicRegisterEnabled": true, "feedbackEnabled": true, "privacyPolicyUrl": null, "termsOfServiceUrl": null, "maxUploadFileSize": null, - "contribPlugins": [], - "debugInfo": false + "contribPlugins": [] }