Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@
angular.module('locale').factory('translationLoader', ['$injector', function translationLoader($injector) {

// Required services
var $document = $injector.get('$document');
var $http = $injector.get('$http');
var $q = $injector.get('$q');
var cacheService = $injector.get('cacheService');
var languageService = $injector.get('languageService');

/**
* The current build identifier, if available. This is used for
* cache-busting translation file requests between deployments.
*
* @type {String}
*/
const buildMeta = $document[0].querySelector('meta[name="build"]');

/**
* Satisfies a translation request for the given key by searching for the
* translation files for each key in the given array, in order. The request
Expand Down Expand Up @@ -82,11 +91,17 @@ angular.module('locale').factory('translationLoader', ['$injector', function tra
return;
}

// Construct translation URL; append ?b=<build>
// when meta is present to avoid stale cached JSON after deploy.
const translationURL = 'translations/' + encodeURIComponent(currentKey) + '.json'
+ ((buildMeta && buildMeta.content) ? ('?b='
+ encodeURIComponent(buildMeta.content)) : '');

// Attempt to retrieve language
$http({
cache : cacheService.languages,
method : 'GET',
url : 'translations/' + encodeURIComponent(currentKey) + '.json'
url : translationURL
})

// Resolve promise if translation retrieved successfully
Expand Down
2 changes: 2 additions & 0 deletions guacamole/src/main/frontend/src/app/login/directives/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
var $route = $injector.get('$route');
var $translate = $injector.get('$translate');
var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService');
var requestService = $injector.get('requestService');

/**
Expand Down Expand Up @@ -226,6 +227,7 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
// after route change has succeeded as this can take time)
// and refresh the translation
$rootScope.$on('guacLogin', function loginSuccessful() {
cacheService.languages.removeAll();
$route.reload();
$translate.refresh();
});
Expand Down
Loading