import settings from 'settings'; import { LocaleUrlStrategy } from '../localization'; export const getUrlPathWithLocale = ( pathname: string, currentLocale?: string ) => { const { defaultLocaleValue, localeUrlStrategy } = settings.localization; if (!currentLocale) { currentLocale = defaultLocaleValue; } if (localeUrlStrategy === LocaleUrlStrategy.Subdomain) { return pathname; } if (localeUrlStrategy === LocaleUrlStrategy.HideAllLocales) { return pathname; } if (localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale) { if (currentLocale === defaultLocaleValue) { return pathname; } else { return `/${currentLocale}${pathname}`; } } if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) { return `/${currentLocale}${pathname}`; } };