From 5d2c8369389013895264caf16e71d44bddabb22c Mon Sep 17 00:00:00 2001 From: physcik Date: Sat, 11 Apr 2026 16:40:22 +0500 Subject: Language toggle --- front/src/Emelents/Topbar.tsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'front/src/Emelents/Topbar.tsx') diff --git a/front/src/Emelents/Topbar.tsx b/front/src/Emelents/Topbar.tsx index 6c4ef74..667b42f 100644 --- a/front/src/Emelents/Topbar.tsx +++ b/front/src/Emelents/Topbar.tsx @@ -1,12 +1,31 @@ +import { useContext } from "react"; +import { LanguageContext } from "../Locales/Context"; +import { GetString } from "../Locales/Locales"; + +const defaultPathName = 'index'; + function Topbar() { + var language = useContext(LanguageContext); + let path = getTopbarElement(window.location.pathname); + return (

View from the edge

-

Lifepath

+

{GetString(path, language)}

); } +// Extracts the black part thing from the path +function getTopbarElement(fullPath: string): string { + let path = fullPath.replace('/', ''); + if (path.length === 0) { + path = defaultPathName; + } + + return path.split('/')[0]; +} + export default Topbar; -- cgit v1.3