keycloakify 11.15.12 → 11.15.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.15.12",
3
+ "version": "11.15.13",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -124,6 +124,56 @@ redirect_to_dev_server: {
124
124
 
125
125
  }
126
126
 
127
+ // See: https://github.com/keycloakify/keycloakify/issues/1044
128
+ normalize_current_language_tag: {
129
+ const locale = kcContext.locale;
130
+
131
+ if( !locale ){
132
+ break normalize_current_language_tag;
133
+ }
134
+
135
+ const currentLanguageTag = locale.currentLanguageTag;
136
+ const supported = locale.supported;
137
+
138
+ if( typeof currentLanguageTag !== "string" || !Array.isArray(supported) ){
139
+ break normalize_current_language_tag;
140
+ }
141
+
142
+ const supportedLanguageTags = supported
143
+ .map(function(supportedLocale){
144
+ return supportedLocale && supportedLocale.languageTag;
145
+ })
146
+ .filter(function(languageTag){
147
+ return typeof languageTag === "string";
148
+ });
149
+
150
+ if( supportedLanguageTags.indexOf(currentLanguageTag) !== -1 ){
151
+ break normalize_current_language_tag;
152
+ }
153
+
154
+ const normalizedCurrentLanguageTag = currentLanguageTag
155
+ .toLowerCase()
156
+ .replace(/_/g, "-");
157
+ const matchingLanguageTags = supportedLanguageTags.filter(function(languageTag){
158
+ return languageTag.toLowerCase().replace(/_/g, "-") === normalizedCurrentLanguageTag;
159
+ });
160
+
161
+ if( matchingLanguageTags.length === 1 ){
162
+ locale.currentLanguageTag = matchingLanguageTags[0];
163
+ break normalize_current_language_tag;
164
+ }
165
+
166
+ console.error(
167
+ "Keycloak returned a locale.currentLanguageTag that does not exactly match a supported locale, and Keycloakify could not correct it unambiguously. Please open an issue with Keycloak and include this diagnostic context.",
168
+ {
169
+ currentLanguageTag: currentLanguageTag,
170
+ normalizedCurrentLanguageTag: normalizedCurrentLanguageTag,
171
+ matchingLanguageTags: matchingLanguageTags,
172
+ supportedLanguageTags: supportedLanguageTags,
173
+ locale: locale
174
+ }
175
+ );
176
+ }
127
177
 
128
178
  window.kcContext = kcContext;
129
179