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