Skip to content

Commit

Permalink
Merge pull request #202 from Chupalika/master
Browse files Browse the repository at this point in the history
fixed an issue where some missing translations would show up empty instead of defaulting to english
  • Loading branch information
Chupalika authored Jan 5, 2025
2 parents f6fb776 + 7961a4c commit b19f6c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import MenuItem, { MenuItemProps } from "antd/lib/menu/MenuItem";
import { Menu, MenuProps, Typography } from "antd";

export function LoginMenuItem(props: UserProps & MenuItemProps) {
const UI = contentManager.getLocalizedUI(useContext(LanguageContext));

const data = props.user?.userid
? {
onClick: () => logout(props.setUser),
label: UI.logout,
label: contentManager.getLocalizedString(useContext(LanguageContext), "logout"),
}
: {
onClick: () => login(props.setUser),
label: UI.login,
label: contentManager.getLocalizedString(useContext(LanguageContext), "login"),
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ export function LoginButton(props: LoginButtonProps) {

// Not logged in
if (!user?.username) {
const UI = contentManager.getLocalizedUI(useContext(LanguageContext));

return (
<Button
type="primary"
className={"login LoginButton-button"}
onClick={() => login(setUser)}
>
{UI.login}
{contentManager.getLocalizedString(useContext(LanguageContext), "login")}
</Button>
);
}
Expand Down
11 changes: 5 additions & 6 deletions client/src/components/modules/UserModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function UserModal({
onValuesChange,
}) {
const discordLoginFlow = () => showAuthPopup("/auth/login-discord", setUser);
const UI = contentManager.getLocalizedUI(useContext(LanguageContext));

return (
<Modal
Expand All @@ -69,21 +68,21 @@ function UserModal({
</div>

<Form {...layout} onValuesChange={onValuesChange} initialValues={user}>
<Form.Item label={UI.userSettings.discord}>
<Form.Item label={contentManager.getLocalizedString(useContext(LanguageContext), "userSettings.discord")}>
{user.discordId ? (
<div>
<span style={{ paddingRight: 8 }}>{user.discord}</span>
<Button type="primary" onClick={discordLoginFlow}>
{UI.userSettings.discordUpdate}
{contentManager.getLocalizedString(useContext(LanguageContext), "userSettings.discordUpdate")}
</Button>
</div>
) : (
<Button type="primary" onClick={discordLoginFlow}>
{UI.userSettings.discordLink}
{contentManager.getLocalizedString(useContext(LanguageContext), "userSettings.discordLink")}
</Button>
)}
</Form.Item>
<Form.Item name="timezone" label={UI.userSettings.timezone}>
<Form.Item name="timezone" label={contentManager.getLocalizedString(useContext(LanguageContext), "userSettings.timezone")}>
<Select placeholder="UTC+0">
{timezones.map((num) => (
<Select.Option key={num} value={num}>
Expand All @@ -110,7 +109,7 @@ function UserModal({
</Form>

<div>
<span className="u-bold">{UI.userSettings.tournies}: </span>
<span className="u-bold">{contentManager.getLocalizedString(useContext(LanguageContext), "userSettings.tournies")}: </span>
{user.tournies && user.tournies.length ? user.tournies.join(", ") : "none"}
</div>
</Modal>
Expand Down
11 changes: 5 additions & 6 deletions client/src/components/pages/TourneyHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function TourneyHome({ tourney, user, setUser }) {
const [showRegisterAsTeam, setShowRegisterAsTeam] = useState(false);
const [teamModalLoading, setTeamModalLoading] = useState(false);
const lang = useContext(LanguageContext);
const UI = contentManager.getLocalizedUI(lang);

const infoRef = React.createRef();
const rulesRef = React.createRef();
Expand Down Expand Up @@ -177,7 +176,7 @@ function TourneyHome({ tourney, user, setUser }) {

const isRegistered = () => user.tournies && user.tournies.includes(tourney);

let regMessage = UI.register;
let regMessage = contentManager.getLocalizedString(useContext(LanguageContext), "register");
let onRegClick = () => register(user);
if (!user._id) {
onRegClick = () => login(setUser).then((user) => register(user));
Expand Down Expand Up @@ -228,12 +227,12 @@ function TourneyHome({ tourney, user, setUser }) {
<div className="TourneyHome-button-box">
<div>
<Button block size="large" onClick={() => scrollToRef(infoRef)}>
{UI.information}
{contentManager.getLocalizedString(useContext(LanguageContext), "information")}
</Button>
</div>
<div>
<Button block size="large" onClick={() => scrollToRef(rulesRef)}>
{UI.rules}
{contentManager.getLocalizedString(useContext(LanguageContext), "rules")}
</Button>
</div>
{content.links && (
Expand All @@ -256,7 +255,7 @@ function TourneyHome({ tourney, user, setUser }) {
}
>
<Button block size="large">
{UI.links}
{contentManager.getLocalizedString(useContext(LanguageContext), "links")}
</Button>
</Dropdown>
</div>
Expand All @@ -269,7 +268,7 @@ function TourneyHome({ tourney, user, setUser }) {
{content.submissions && (
<div>
<Button block size="large" target="_blank" href={content.submissions}>
{UI.submissions}
{contentManager.getLocalizedString(useContext(LanguageContext), "submissions")}
</Button>
</div>
)}
Expand Down

0 comments on commit b19f6c8

Please sign in to comment.