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

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


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

commit 8d143e83677c6a40ac13bc9f98404dcc6817cc36
Author: Rob Fellows <[email protected]>
AuthorDate: Mon Jan 24 13:43:23 2022 -0500

    [NIFI-9623] - Attempt to look up messages locale file without country 
designation if it fails to find it with the country designation
    
    Signed-off-by: Nathan Gough <[email protected]>
    
    This closes #5707.
---
 .../src/main/webapp/nf-registry-bootstrap.js       | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git 
a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry-bootstrap.js
 
b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry-bootstrap.js
index 4ad63a8..62648eb 100644
--- 
a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry-bootstrap.js
+++ 
b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry-bootstrap.js
@@ -60,7 +60,27 @@ if (!locale || locale === 'en-us') {
         }
         bootstrapModule();
     }).fail(function () {
-        bootstrapModule();
+        // 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 = '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]});
+                }
+                bootstrapModule();
+            }).fail(function () {
+                bootstrapModule();
+            });
+        } else {
+            bootstrapModule();
+        }
     });
 }
 

Reply via email to