necouchman commented on a change in pull request #710:
URL: https://github.com/apache/guacamole-client/pull/710#discussion_r839054517



##########
File path: guacamole/src/main/frontend/src/app/client/services/guacTranslate.js
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A wrapper around the angular-translate $translate service that offers a
+ * convenient way to fall back to a default translation if the requested
+ * translation is not available.
+ */
+ angular.module('client').factory('guacTranslate', ['$injector', function 
guacTranslate($injector) {
+
+    // Required services
+    const $q = $injector.get('$q');
+    const $translate = $injector.get('$translate');
+
+    // Required types
+    const TranslationResult = $injector.get('TranslationResult');
+
+    /**
+     * Returns a promise that will be resolved with a TranslationResult 
containg either the
+     * requested ID and message (if translated), or the default ID and message 
if translated,
+     * or the literal value of `defaultTranslationId` for both the ID and 
message if neither
+     * is translated.
+     *
+     * @param {String} translationId
+     *     The requested translation ID, which may or may not be translated.
+     *
+     * @param {Sting} defaultTranslationId
+     *     The translation ID that will be used if no translation is found for 
`translationId`.
+     *
+     * @returns {Promise.<TranslationResult>}
+     *     A promise which resolves with a TranslationResult containing the 
results from
+     *     the translation attempt.
+     */
+    function translateWithFallback(translationId, defaultTranslationId) {

Review comment:
       I'm a little unsure on this one, but should this line be:
   ```
   var translateWithFallback = function translateWithFallback(translationId, 
defaultTranslationId) {
   ```
   since you `return translateWithFallback` below? I'm a little unsure what the 
acceptable/preferred ways are to do that??

##########
File path: 
guacamole/src/main/frontend/src/app/client/directives/guacClientNotification.js
##########
@@ -65,26 +66,6 @@ angular.module('client').directive('guacClientNotification', 
[function guacClien
          */
         $scope.status = false;
 
-        /**
-         * All client error codes handled and passed off for translation. Any 
error
-         * code not present in this list will be represented by the "DEFAULT"
-         * translation.
-         */
-        const CLIENT_ERRORS = {
-            0x0201: true,
-            0x0202: true,
-            0x0203: true,
-            0x0207: true,
-            0x0208: true,
-            0x0209: true,
-            0x020A: true,
-            0x020B: true,
-            0x0301: true,
-            0x0303: true,
-            0x0308: true,
-            0x031D: true
-        };

Review comment:
       Are these error codes not needed at all anymore? I see that they're 
removed here and in the `guacFileTransfer.js` file, but do they not need to be 
defined at all?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to