wait translation before resolving the page
parent
e1d36a82c3
commit
4ac3f2902e
|
@ -40,6 +40,24 @@ taiga.sessionId = taiga.generateUniqueSessionIdentifier()
|
||||||
|
|
||||||
configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider,
|
configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider,
|
||||||
$compileProvider, $translateProvider) ->
|
$compileProvider, $translateProvider) ->
|
||||||
|
|
||||||
|
# wait until the trasnlation is ready to resolve the page
|
||||||
|
originalWhen = $routeProvider.when
|
||||||
|
|
||||||
|
$routeProvider.when = (path, route) ->
|
||||||
|
route.resolve || (route.resolve = {})
|
||||||
|
angular.extend(route.resolve, {
|
||||||
|
languageLoad: ["$q", "$translate", ($q, $translate) ->
|
||||||
|
deferred = $q.defer()
|
||||||
|
|
||||||
|
$translate().then () -> deferred.resolve()
|
||||||
|
|
||||||
|
return deferred.promise
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
return originalWhen.call($routeProvider, path, route)
|
||||||
|
|
||||||
$routeProvider.when("/",
|
$routeProvider.when("/",
|
||||||
{
|
{
|
||||||
templateUrl: "home/home.html",
|
templateUrl: "home/home.html",
|
||||||
|
@ -541,6 +559,10 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
|
||||||
# Analytics
|
# Analytics
|
||||||
$analytics.initialize()
|
$analytics.initialize()
|
||||||
|
|
||||||
|
$rootscope.$on '$routeChangeStart', (event, next) ->
|
||||||
|
if next.loader
|
||||||
|
loaderService.startWithAutoClose()
|
||||||
|
|
||||||
$rootscope.$on '$routeChangeSuccess', (event, next) ->
|
$rootscope.$on '$routeChangeSuccess', (event, next) ->
|
||||||
if next.access && next.access.requiresLogin
|
if next.access && next.access.requiresLogin
|
||||||
if !$auth.isAuthenticated()
|
if !$auth.isAuthenticated()
|
||||||
|
@ -554,13 +576,10 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
|
||||||
projectService.cleanProject()
|
projectService.cleanProject()
|
||||||
|
|
||||||
if next.title or next.description
|
if next.title or next.description
|
||||||
title = next.title or ""
|
title = $translate.instant(next.title or "")
|
||||||
description = next.description or ""
|
description = $translate.instant(next.description or "")
|
||||||
$translate([title, description]).then (translations) =>
|
appMetaService.setAll(title, description)
|
||||||
appMetaService.setAll(translations[title], translations[description])
|
|
||||||
|
|
||||||
if next.loader
|
|
||||||
loaderService.startWithAutoClose()
|
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main Global Modules
|
# Main Global Modules
|
||||||
|
|
|
@ -792,9 +792,7 @@ module.directive("tgProgressBar", ["$tgTemplate", TgProgressBarDirective])
|
||||||
TgMainTitleDirective = ($translate) ->
|
TgMainTitleDirective = ($translate) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$attrs.$observe "i18nSectionName", (i18nSectionName) ->
|
$attrs.$observe "i18nSectionName", (i18nSectionName) ->
|
||||||
trans = $translate(i18nSectionName)
|
$scope.sectionName = $translate.instant(i18nSectionName)
|
||||||
trans.then (sectionName) -> $scope.sectionName = sectionName
|
|
||||||
trans.catch (sectionName) -> $scope.sectionName = sectionName
|
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
|
@ -154,8 +154,8 @@ module.directive("lightbox", ["lightboxService", LightboxDirective])
|
||||||
|
|
||||||
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue, $translate) ->
|
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue, $translate) ->
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
$translate($attrs.title).then (title) ->
|
title = $translate.instant($attrs.title)
|
||||||
$el.find("h2.title").text(title)
|
$el.find("h2.title").text(title)
|
||||||
|
|
||||||
unblock = $qqueue.bindAdd (item, finishCallback) =>
|
unblock = $qqueue.bindAdd (item, finishCallback) =>
|
||||||
promise = $tgrepo.save(item)
|
promise = $tgrepo.save(item)
|
||||||
|
|
|
@ -60,8 +60,8 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
|
|
||||||
maxFileSize = @config.get("maxUploadFileSize", null)
|
maxFileSize = @config.get("maxUploadFileSize", null)
|
||||||
if maxFileSize
|
if maxFileSize
|
||||||
@translate("USER_SETTINGS.AVATAR_MAX_SIZE", {"maxFileSize": sizeFormat(maxFileSize)}).then (text) =>
|
text = @translate.instant("USER_SETTINGS.AVATAR_MAX_SIZE", {"maxFileSize": sizeFormat(maxFileSize)})
|
||||||
@scope.maxFileSizeMsg = text
|
@scope.maxFileSizeMsg = text
|
||||||
|
|
||||||
promise = @.loadInitialData()
|
promise = @.loadInitialData()
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,9 @@ class ProfileHints
|
||||||
|
|
||||||
@.hint.linkText = @.hint.linkText || 'HINTS.LINK'
|
@.hint.linkText = @.hint.linkText || 'HINTS.LINK'
|
||||||
|
|
||||||
@translate("HINTS.HINT#{hintKey}_TITLE").then (text) =>
|
@.hint.title = @translate.instant("HINTS.HINT#{hintKey}_TITLE")
|
||||||
@.hint.title = text
|
|
||||||
|
|
||||||
@translate("HINTS.HINT#{hintKey}_TEXT").then (text) =>
|
@.hint.text = @translate.instant("HINTS.HINT#{hintKey}_TEXT")
|
||||||
@.hint.text = text
|
|
||||||
|
|
||||||
ProfileHints.$inject = [
|
ProfileHints.$inject = [
|
||||||
"$translate"
|
"$translate"
|
||||||
|
|
|
@ -5,7 +5,8 @@ describe "ProfileHints", ->
|
||||||
mocks = {}
|
mocks = {}
|
||||||
|
|
||||||
_mockTranslate = () ->
|
_mockTranslate = () ->
|
||||||
mocks.translateService = sinon.stub()
|
mocks.translateService = {}
|
||||||
|
mocks.translateService.instant = sinon.stub()
|
||||||
|
|
||||||
$provide.value "$translate", mocks.translateService
|
$provide.value "$translate", mocks.translateService
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ describe "ProfileHints", ->
|
||||||
$controller = _$controller_
|
$controller = _$controller_
|
||||||
|
|
||||||
it "random hint generator", (done) ->
|
it "random hint generator", (done) ->
|
||||||
mocks.translateService.promise().resolve("fill")
|
mocks.translateService.instant.returns("fill")
|
||||||
|
|
||||||
ctrl = $controller("ProfileHints")
|
ctrl = $controller("ProfileHints")
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,9 @@ class ProfileController
|
||||||
userUsername: user.get("username")
|
userUsername: user.get("username")
|
||||||
}
|
}
|
||||||
|
|
||||||
@translate("USER.PROFILE.PAGE_TITLE", ctx).then (title) =>
|
title = @translate.instant("USER.PROFILE.PAGE_TITLE", ctx)
|
||||||
description = user.get("bio")
|
|
||||||
@appMetaService.setAll(title, description)
|
description = user.get("bio")
|
||||||
|
@appMetaService.setAll(title, description)
|
||||||
|
|
||||||
angular.module("taigaProfile").controller("Profile", ProfileController)
|
angular.module("taigaProfile").controller("Profile", ProfileController)
|
||||||
|
|
|
@ -11,7 +11,8 @@ describe "ProfileController", ->
|
||||||
])
|
])
|
||||||
|
|
||||||
_mockTranslate = () ->
|
_mockTranslate = () ->
|
||||||
mocks.translate = sinon.stub()
|
mocks.translate = {}
|
||||||
|
mocks.translate.instant = sinon.stub()
|
||||||
|
|
||||||
provide.value "$translate", mocks.translate
|
provide.value "$translate", mocks.translate
|
||||||
|
|
||||||
|
@ -83,12 +84,12 @@ describe "ProfileController", ->
|
||||||
is_active: true
|
is_active: true
|
||||||
})
|
})
|
||||||
|
|
||||||
mocks.translate
|
mocks.translate.instant
|
||||||
.withArgs('USER.PROFILE.PAGE_TITLE', {
|
.withArgs('USER.PROFILE.PAGE_TITLE', {
|
||||||
userFullName: user.get("full_name_display"),
|
userFullName: user.get("full_name_display"),
|
||||||
userUsername: user.get("username")
|
userUsername: user.get("username")
|
||||||
})
|
})
|
||||||
.promise().resolve('user-profile-page-title')
|
.returns('user-profile-page-title')
|
||||||
|
|
||||||
mocks.userService.getUserByUserName.withArgs(mocks.routeParams.slug).promise().resolve(user)
|
mocks.userService.getUserByUserName.withArgs(mocks.routeParams.slug).promise().resolve(user)
|
||||||
|
|
||||||
|
@ -129,12 +130,12 @@ describe "ProfileController", ->
|
||||||
is_active: true
|
is_active: true
|
||||||
})
|
})
|
||||||
|
|
||||||
mocks.translate
|
mocks.translate.instant
|
||||||
.withArgs('USER.PROFILE.PAGE_TITLE', {
|
.withArgs('USER.PROFILE.PAGE_TITLE', {
|
||||||
userFullName: user.get("full_name_display"),
|
userFullName: user.get("full_name_display"),
|
||||||
userUsername: user.get("username")
|
userUsername: user.get("username")
|
||||||
})
|
})
|
||||||
.promise().resolve('user-profile-page-title')
|
.returns('user-profile-page-title')
|
||||||
|
|
||||||
mocks.currentUser.getUser.returns(user)
|
mocks.currentUser.getUser.returns(user)
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ class ProjectController
|
||||||
_setMeta: (project)->
|
_setMeta: (project)->
|
||||||
ctx = {projectName: project.get("name")}
|
ctx = {projectName: project.get("name")}
|
||||||
|
|
||||||
title = @translate("PROJECT.PAGE_TITLE", ctx).then (title) =>
|
title = @translate.instant("PROJECT.PAGE_TITLE", ctx)
|
||||||
description = project.get("description")
|
description = project.get("description")
|
||||||
@appMetaService.setAll(title, description)
|
@appMetaService.setAll(title, description)
|
||||||
|
|
||||||
angular.module("taigaProjects").controller("Project", ProjectController)
|
angular.module("taigaProjects").controller("Project", ProjectController)
|
||||||
|
|
|
@ -39,7 +39,8 @@ describe "ProjectController", ->
|
||||||
provide.value "tgXhrErrorService", mocks.xhrErrorService
|
provide.value "tgXhrErrorService", mocks.xhrErrorService
|
||||||
|
|
||||||
_mockTranslate = () ->
|
_mockTranslate = () ->
|
||||||
mocks.translate = sinon.stub()
|
mocks.translate = {}
|
||||||
|
mocks.translate.instant = sinon.stub()
|
||||||
|
|
||||||
provide.value "$translate", mocks.translate
|
provide.value "$translate", mocks.translate
|
||||||
|
|
||||||
|
@ -84,11 +85,11 @@ describe "ProjectController", ->
|
||||||
description: "projectDescription"
|
description: "projectDescription"
|
||||||
})
|
})
|
||||||
|
|
||||||
mocks.translate
|
mocks.translate.instant
|
||||||
.withArgs('PROJECT.PAGE_TITLE', {
|
.withArgs('PROJECT.PAGE_TITLE', {
|
||||||
projectName: project.get("name")
|
projectName: project.get("name")
|
||||||
})
|
})
|
||||||
.promise().resolve('projectTitle')
|
.returns('projectTitle')
|
||||||
|
|
||||||
mocks.projectService.getProjectBySlug.withArgs("project-slug").promise().resolve(project)
|
mocks.projectService.getProjectBySlug.withArgs("project-slug").promise().resolve(project)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue