@swan-io/shared-business 2.7.36 → 2.7.38

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": "@swan-io/shared-business",
3
- "version": "2.7.36",
3
+ "version": "2.7.38",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -1,12 +1,13 @@
1
+ import { intersection } from "@swan-io/lake/src/utils/array";
1
2
  import { isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
2
3
  export const LANGUAGE_FALLBACK = "en";
3
4
  const PREFERRED_LANGUAGE_KEY = "swan__PreferredLanguage";
4
5
  let supportedLanguages = undefined;
5
6
  export const getLanguagesHelpers = (languages) => {
6
7
  // Restrict shared-business supported languages to the current project ones
7
- if (isNullish(supportedLanguages)) {
8
- supportedLanguages = languages;
9
- }
8
+ supportedLanguages = isNullish(supportedLanguages)
9
+ ? languages
10
+ : intersection(supportedLanguages, languages);
10
11
  const isSupportedLanguage = (language) => (supportedLanguages ?? []).includes(language);
11
12
  const getFirstSupportedLanguage = (languages) => languages.find(isSupportedLanguage) ?? LANGUAGE_FALLBACK;
12
13
  const getPreferredLanguage = () => {