diff --git a/.env b/.env index 53bc6170..3bfae161 100644 --- a/.env +++ b/.env @@ -5,3 +5,4 @@ REACT_APP_COMPONENTS=YWwtc2dvdi1zZXJ2ZXI6CiAgbmFtZTogU0dvViBTZXJ2aWNlCiAgdXJsOiB BROWSER=none REACT_APP_DEBUG=false REACT_APP_AUTHENTICATION=true +REACT_APP_TERM_LANGUAGE=cs diff --git a/src/components/modals/CreationModals.tsx b/src/components/modals/CreationModals.tsx index 4688928d..0342c769 100644 --- a/src/components/modals/CreationModals.tsx +++ b/src/components/modals/CreationModals.tsx @@ -89,7 +89,6 @@ export const CreationModals: React.FC = (props) => { }} /> = (props) => { const [activatedInputs, setActivatedInputs] = useState([]); useEffect(() => { - setActivatedInputs([AppSettings.canvasLanguage]); + setActivatedInputs([Environment.language]); }, []); const checkExists: (scheme: string, name: string) => boolean = ( @@ -68,7 +68,7 @@ export const NewElemForm: React.FC = (props) => { names: ReturnType ) => { let errorText = ""; - if (names[AppSettings.canvasLanguage] === "") { + if (names[Environment.language] === "") { errorText = Locale[AppSettings.interfaceLanguage].modalNewElemError; } else if (Object.values(names).find((name) => checkExists(scheme, name))) { errorText = Locale[AppSettings.interfaceLanguage].modalNewElemExistsError; @@ -79,7 +79,7 @@ export const NewElemForm: React.FC = (props) => { ) { errorText = Locale[AppSettings.interfaceLanguage].modalNewElemLengthError; } else if ( - createNewElemIRI(scheme, names[AppSettings.canvasLanguage]) === + createNewElemIRI(scheme, names[Environment.language]) === WorkspaceVocabularies[getVocabularyFromScheme(scheme)].namespace ) { errorText = @@ -118,7 +118,7 @@ export const NewElemForm: React.FC = (props) => { src={`https://purecatamphetamine.github.io/country-flag-icons/3x2/${Flags[lang]}.svg`} alt={Languages[lang]} /> - {lang === AppSettings.canvasLanguage ? "*" : ""} + {lang === Environment.language && *} = (props) => { ))} @@ -188,7 +188,7 @@ export const NewElemForm: React.FC = (props) => { } ${createNewElemIRI( WorkspaceVocabularies[props.selectedVocabulary].glossary, - props.termName[AppSettings.interfaceLanguage] + props.termName[Environment.language] )}`} )} {props.errorText && {props.errorText}} diff --git a/src/components/modals/NewElemModal.tsx b/src/components/modals/NewElemModal.tsx index 79747f40..0f863c7e 100644 --- a/src/components/modals/NewElemModal.tsx +++ b/src/components/modals/NewElemModal.tsx @@ -6,11 +6,11 @@ import { ElemCreationConfiguration } from "./CreationModals"; import { initLanguageObject } from "../../function/FunctionEditVars"; import { Locale } from "../../config/Locale"; import { NewElemForm } from "./NewElemForm"; +import { Environment } from "../../config/Environment"; interface Props { modal: boolean; close: (names?: State["termName"], vocabulary?: string) => void; - projectLanguage: string; configuration: ElemCreationConfiguration; } @@ -76,7 +76,7 @@ export default class NewElemModal extends React.Component { Locale[AppSettings.interfaceLanguage].modalNewElemError, }); const input = document.getElementById( - "newElemLabelInput" + this.props.projectLanguage + "newElemLabelInput" + Environment.language ); if (input) input.focus(); }} @@ -93,7 +93,6 @@ export default class NewElemModal extends React.Component { {this.state.selectedVocabulary && ( { /> {this.state.create && ( (); @@ -22,6 +26,8 @@ export const Environment: { auth: boolean; // Load local debug data instead of fetching off a DB debug: boolean; + // Default language + language: string; } = { components: ENV.getComponents(), context: ENV.get("CONTEXT"), @@ -29,4 +35,5 @@ export const Environment: { url: ENV.get("URL"), auth: ENV.get("AUTHENTICATION", "true") === "true", debug: ENV.get("DEBUG", "true") === "true", + language: ENV.get("TERM_LANGUAGE"), }; diff --git a/src/interface/ContextInterface.tsx b/src/interface/ContextInterface.tsx index 0df1612b..31d037a4 100644 --- a/src/interface/ContextInterface.tsx +++ b/src/interface/ContextInterface.tsx @@ -8,6 +8,7 @@ import { StoreSettings } from "../config/Store"; import { AppSettings, Diagrams, + Languages, Links, WorkspaceElements, WorkspaceLinks, @@ -51,8 +52,13 @@ import { updateProjectLinkParallel, } from "../queries/update/UpdateLinkQueries"; import { processQuery, processTransaction } from "./TransactionInterface"; +import { Environment } from "../config/Environment"; export function retrieveInfoFromURLParameters(): boolean { + if (!(Environment.language in Languages)) + throw new Error( + "TERM_LANGUAGE environment variable is not listed in the Languages.ts object." + ); const isURL = require("is-url"); const urlParams = new URLSearchParams(window.location.search); const URIContexts = urlParams.getAll("vocabulary");