You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
540 B
27 lines
540 B
/**
|
|
* This file contains several utils functions
|
|
*/
|
|
|
|
import {NextRouter} from 'next/router';
|
|
|
|
export const getLocaleShort = (router: NextRouter): string => {
|
|
if (!router.locale) {
|
|
return router.defaultLocale.substring(0, 2).toUpperCase();
|
|
}
|
|
|
|
if (router.locale.startsWith("en")) {
|
|
return "GB";
|
|
}
|
|
|
|
return router.locale.substring(0, 2).toUpperCase();
|
|
}
|
|
|
|
|
|
|
|
export const getWindowUrl = (): string => {
|
|
return typeof window !== 'undefined' && window.location.origin
|
|
? window.location.origin
|
|
: 'http://localhost';
|
|
}
|
|
|