Replies: 1 comment
-
You can get the current language using the import i18next from "i18next";
const currentLanguage = i18next.language; You may browse the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be great to have a utility function/variable to get the currently active locale (e.g.,
en
,de
, etc.), so it can be used, e.g. in custom language switcher styling to set the active state on the element depending on the current locale.The current workaround is to extract the locale name from the URL, which is not very convenient because there is no access to
window
in native Astro code blocks, so you can't set the class dynamically viaclass:list
, and have to fall back to<script>
tags and native DOM methods.Beta Was this translation helpful? Give feedback.
All reactions