summaryrefslogtreecommitdiff
path: root/src/lib/correctLocaleCasing.ts
blob: 4a0f6694855612f9fffe30db53dd35941118a2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import locales from '$i18n/locales';

export function correctLocaleCasing(str: string) {
  const strLowercase = str.toLowerCase();

  for (const locale of locales) {
    if (strLowercase === locale.toLowerCase()) {
      return locale;
    }
  }

  return str;
}