This is an automated email from the ASF dual-hosted git repository.

scottyaslan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-fds.git


The following commit(s) were added to refs/heads/main by this push:
     new 4fea002  NIFI-6732 - Attempt to look up messages locale file without 
country designation if it fails to find it with the country designation.
4fea002 is described below

commit 4fea002723f630b786fca05036329f0ad7b57393
Author: Rob Fellows <[email protected]>
AuthorDate: Mon Sep 30 15:49:20 2019 -0400

    NIFI-6732 - Attempt to look up messages locale file without country 
designation if it fails to find it with the country designation.
    
    This closes #61
    
    Signed-off-by: Scott Aslan <[email protected]>
---
 webapp/fds-bootstrap.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/webapp/fds-bootstrap.js b/webapp/fds-bootstrap.js
index b2cbf9f..4d6003b 100644
--- a/webapp/fds-bootstrap.js
+++ b/webapp/fds-bootstrap.js
@@ -53,6 +53,26 @@ if (!locale || locale === 'en-us') {
         }
         platformBrowserDynamic().bootstrapModule(FdsModule, {providers: 
providers});
     }).fail(function () {
-        platformBrowserDynamic().bootstrapModule(FdsModule, {providers: 
providers});
+        // was this a country specific locale? if so, try to get the generic 
version of the language
+        const localeTokens = locale.split('-');
+        if (localeTokens.length === 2) {
+            translationFile = './webapp/locale/messages.' + localeTokens[0] + 
'.xlf';
+            $.ajax({
+                url: translationFile,
+                dataType: 'text'
+            }).done(function (translations) {
+                // add providers if translation file for locale is loaded
+                if (translations) {
+                    providers.push({provide: TRANSLATIONS, useValue: 
translations});
+                    providers.push({provide: TRANSLATIONS_FORMAT, useValue: 
'xlf'});
+                    providers.push({provide: LOCALE_ID, useValue: 
localeTokens[0]});
+                }
+                platformBrowserDynamic().bootstrapModule(FdsModule, 
{providers: providers});
+            }).fail(function () {
+                platformBrowserDynamic().bootstrapModule(FdsModule, 
{providers: providers});
+            });
+        } else {
+            platformBrowserDynamic().bootstrapModule(FdsModule, {providers: 
providers});
+        }
     });
 }

Reply via email to