Skip to content

Commit

Permalink
Restore translationkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt committed Aug 20, 2024
1 parent c649b5a commit d78ed6f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/client/src/auth/translationKeys/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./translationKeys.jsx";
13 changes: 13 additions & 0 deletions src/client/src/auth/translationKeys/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from "styled-components";

export const Container = styled.div`
/* background-color: red; */
`;

export const Keys = styled.span`
cursor: pointer;
padding: 0.2em;
color: black;
font-size: 13px;
font-weight: 100;
`;
63 changes: 63 additions & 0 deletions src/client/src/auth/translationKeys/translationKeys.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useState, useEffect } from "react";
import * as Styled from "./styles.js";
import { withTranslation } from "react-i18next";

const TranslationKeys = prop => {
const [selectedLanguage, setSelectedLanguage] = useState();

const languages = [
{ id: 0, language: "de" },
{ id: 1, language: "fr" },
{ id: 2, language: "it" },
{ id: 3, language: "en" },
];

useEffect(() => {
let lang;

switch (prop.i18n.language) {
case "de":
lang = languages[0];
break;
case "fr":
lang = languages[1];
break;
case "it":
lang = languages[2];
break;
case "en":
lang = languages[3];
break;
default:
lang = languages[0];
}
setSelectedLanguage(lang);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [prop.i18n.language]);

return (
<Styled.Container>
{languages.map((item, key) => (
<Styled.Keys
key={key}
onClick={() => {
setSelectedLanguage(item);
if (prop?.ignori18n) {
prop.handleSelectedLanguage(item.language);
} else {
prop.i18n.changeLanguage(item.language);
}
}}
style={{
color: selectedLanguage?.language === item.language ? "red" : "black",
textDecoration: selectedLanguage?.language === item.language ? "underline" : "none",
}}>
{item.language.toUpperCase()}
</Styled.Keys>
))}
</Styled.Container>
);
};

const TranslatedKeys = withTranslation("common")(TranslationKeys);
export default TranslatedKeys;
5 changes: 0 additions & 5 deletions src/client/src/pages/settings/termSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import PropTypes from "prop-types";
import { withTranslation } from "react-i18next";
import Markdown from "markdown-to-jsx";
import { Button, Form, Modal, TextArea } from "semantic-ui-react";

import TranslationKeys from "../../auth/translationKeys";

import { draftTerms, getTermsDraft, publishTerms } from "../../api-lib/index";

class TermSettings extends React.Component {
Expand Down Expand Up @@ -241,9 +239,6 @@ TermSettings.propTypes = {
user: PropTypes.object,
};

// TermSettings.defaultProps = {
// };

const mapStateToProps = state => {
return {
user: state.core_user,
Expand Down

0 comments on commit d78ed6f

Please sign in to comment.