Web: Files: fixed circular dependency
This commit is contained in:
parent
9ac5f66ead
commit
d94a45bc4a
27
packages/client/src/helpers/language-helpers.js
Normal file
27
packages/client/src/helpers/language-helpers.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { getLanguage } from "@docspace/shared/utils";
|
||||||
|
import { translations } from "./autoGeneratedTranslations";
|
||||||
|
|
||||||
|
export function loadLanguagePath(homepage, fixedNS = null) {
|
||||||
|
return (lng, ns) => {
|
||||||
|
const language = getLanguage(lng instanceof Array ? lng[0] : lng);
|
||||||
|
|
||||||
|
const lngCollection = translations?.get(language);
|
||||||
|
|
||||||
|
const data = lngCollection?.get(`${fixedNS || ns}`);
|
||||||
|
|
||||||
|
if (!data) return `/locales/${language}/${fixedNS || ns}.json`;
|
||||||
|
|
||||||
|
let path = data?.split("/");
|
||||||
|
const length = path?.length;
|
||||||
|
|
||||||
|
const isCommonPath = path[length - 1].indexOf("Common") > -1;
|
||||||
|
|
||||||
|
path = `/${path[length - 3]}/${path[length - 2]}/${path[length - 1]}`;
|
||||||
|
|
||||||
|
if (ns.length > 0 && ns[0] === "Common" && isCommonPath) {
|
||||||
|
return `/static${path}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
};
|
||||||
|
}
|
@ -25,12 +25,10 @@
|
|||||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||||
|
|
||||||
import { authStore } from "@docspace/shared/store";
|
import { authStore } from "@docspace/shared/store";
|
||||||
import { getLanguage } from "@docspace/shared/utils";
|
|
||||||
import { toCommunityHostname } from "@docspace/shared/utils/common";
|
import { toCommunityHostname } from "@docspace/shared/utils/common";
|
||||||
|
|
||||||
import { CategoryType } from "./constants";
|
import { CategoryType } from "./constants";
|
||||||
import { FolderType, ShareAccessRights } from "@docspace/shared/enums";
|
import { FolderType } from "@docspace/shared/enums";
|
||||||
import { translations } from "./autoGeneratedTranslations";
|
|
||||||
// import router from "SRC_DIR/router";
|
// import router from "SRC_DIR/router";
|
||||||
import i18n from "../i18n";
|
import i18n from "../i18n";
|
||||||
|
|
||||||
@ -54,31 +52,6 @@ export const setDocumentTitle = (subTitle = "") => {
|
|||||||
document.title = title;
|
document.title = title;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function loadLanguagePath(homepage, fixedNS = null) {
|
|
||||||
return (lng, ns) => {
|
|
||||||
const language = getLanguage(lng instanceof Array ? lng[0] : lng);
|
|
||||||
|
|
||||||
const lngCollection = translations?.get(language);
|
|
||||||
|
|
||||||
const data = lngCollection?.get(`${fixedNS || ns}`);
|
|
||||||
|
|
||||||
if (!data) return `/locales/${language}/${fixedNS || ns}.json`;
|
|
||||||
|
|
||||||
let path = data?.split("/");
|
|
||||||
const length = path?.length;
|
|
||||||
|
|
||||||
const isCommonPath = path[length - 1].indexOf("Common") > -1;
|
|
||||||
|
|
||||||
path = `/${path[length - 3]}/${path[length - 2]}/${path[length - 1]}`;
|
|
||||||
|
|
||||||
if (ns.length > 0 && ns[0] === "Common" && isCommonPath) {
|
|
||||||
return `/static${path}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const checkIfModuleOld = (link) => {
|
export const checkIfModuleOld = (link) => {
|
||||||
if (
|
if (
|
||||||
!link ||
|
!link ||
|
||||||
|
@ -31,7 +31,7 @@ import config from "PACKAGE_FILE";
|
|||||||
import { LANGUAGE } from "@docspace/shared/constants";
|
import { LANGUAGE } from "@docspace/shared/constants";
|
||||||
import { getCookie } from "@docspace/shared/utils";
|
import { getCookie } from "@docspace/shared/utils";
|
||||||
|
|
||||||
import { loadLanguagePath } from "./helpers/utils";
|
import { loadLanguagePath } from "./helpers/language-helpers";
|
||||||
|
|
||||||
const newInstance = i18n.createInstance();
|
const newInstance = i18n.createInstance();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user