Set default language from configuration and get locale list from the server

stable
David Barragán Merino 2015-04-14 13:06:30 +02:00
parent 97767e5d3a
commit ea1c3c19b9
8 changed files with 58 additions and 10 deletions

View File

@ -3,6 +3,7 @@ window.taigaConfig = {
"api": "http://localhost:8000/api/v1/",
"eventsUrl": null,
"debug": true,
"defaultLanguage": "en",
"publicRegisterEnabled": true,
"feedbackEnabled": true,
"privacyPolicyUrl": null,

View File

@ -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")

View File

@ -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
])

View File

@ -0,0 +1,38 @@
###
# Copyright (C) 2015 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2015 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2015 David Barragán Merino <bameda@dbarragan.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
# 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])

View File

@ -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)

View File

@ -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 <br />edit",
"LAST_MODIFICATION": "last modification"
}
},
"LANGUAGES": {
"ENGLISH": "English"
}
}

View File

@ -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")

View File

@ -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": []
}