How to use the function in piral-core

To help you get started, we’ve selected a few piral-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smapiot / piral / src / packages / piral-translate / src / current.ts View on Github external
function getUserLocaleUnchecked(defaultLocale: string, remoteLocale: string) {
  const storedLocale = cookie.getItem('_culture') || storage.getItem('locale');

  if (storedLocale) {
    return storedLocale;
  } else if (remoteLocale) {
    return remoteLocale.toLowerCase().substring(0, 2);
  } else if (navigator.language) {
    return navigator.language.substring(0, 2);

  return defaultLocale;