mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-1217: Fallback to standard dialects when no specific dialect is available/requested.
This commit is contained in:
		| @@ -30,7 +30,7 @@ angular.module('index').config(['$injector', function($injector) { | ||||
|     var preferenceServiceProvider = $injector.get('preferenceServiceProvider'); | ||||
|  | ||||
|     // Fallback to US English | ||||
|     var fallbackLanguages = ['en_US']; | ||||
|     var fallbackLanguages = ['en']; | ||||
|  | ||||
|     // Prefer chosen language, use fallback languages if necessary | ||||
|     $translateProvider.fallbackLanguage(fallbackLanguages); | ||||
|   | ||||
| @@ -81,6 +81,31 @@ angular.module('locale').factory('translationLoader', ['$injector', function tra | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Given a valid language key, returns all possible legal variations of | ||||
|      * that key. Currently, this will be the given key and the given key | ||||
|      * without the country code. If the key has no country code, only the | ||||
|      * given key will be included in the returned array. | ||||
|      * | ||||
|      * @param {String} key | ||||
|      *     The language key to generate variations of. | ||||
|      * | ||||
|      * @returns {String[]} | ||||
|      *     All possible variations of the given language key. | ||||
|      */ | ||||
|     var getKeyVariations = function getKeyVariations(key) { | ||||
|  | ||||
|         var underscore = key.indexOf('_'); | ||||
|  | ||||
|         // If no underscore, only one possibility | ||||
|         if (underscore === -1) | ||||
|             return [key]; | ||||
|  | ||||
|         // Otherwise, include the lack of country code as an option | ||||
|         return [key, key.substr(0, underscore)]; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Custom loader function for angular-translate which loads the desired | ||||
|      * language file dynamically via HTTP. If the language file cannot be | ||||
| @@ -101,7 +126,7 @@ angular.module('locale').factory('translationLoader', ['$injector', function tra | ||||
|         var requestedKey = options.key; | ||||
|  | ||||
|         // Append fallback languages to requested language | ||||
|         var keys = [requestedKey].concat(options.fallbackLanguages); | ||||
|         var keys = getKeyVariations(requestedKey).concat(options.fallbackLanguages); | ||||
|  | ||||
|         // Satisfy the translation request | ||||
|         satisfyTranslation(translation, requestedKey, keys); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user