Detecting the Currently selected locale

How to detect the currently selected locale so that you can use it in your React components.

To detect the currently selected locale from the client or the server, you can use the useTranslation hook from next-i18next.

import { useTranslation } from 'next-i18next';
function Component() {
const { i18n } = useTranslation();
const { language } = i18n;
// use language here
}