aboutsummaryrefslogtreecommitdiff
path: root/src/i18n/index.ts
blob: 3e6083b8bd99d9afa9f20b95de78525717522c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Spanish from "./es.json";
import English from "./en.json";

export const SHOW_DEFAULT_LANGUAGE = false;
export const DEFAULT_LANGUAGE = "es";

export type LanguageKeys = "es" | "en";

export const languages: Record<LanguageKeys, { code: string; name: string }> = {
  es: {
    code: "es",
    name: "Español",
  },
  en: {
    code: "en",
    name: "English",
  },
};

export const LANGUAGE_CODES = Object.keys(languages);

export const useTranslations = (lang: string | undefined) => {
  switch (lang) {
    case languages.en.code:
      return English;
    case languages.es.code:
    default:
      return Spanish;
  }
};

export function getUrlWithoutLocale(url: string) {
  return url.replace(/\/[a-z]{2}\//, "/");
}