Browse Source

PR fixes

pull/664/head
Dan Ditomaso 1 year ago
parent
commit
eabbe4ef8f
  1. 34
      src/i18n/config.ts
  2. 1
      vite.config.ts

34
src/i18n/config.ts

@ -7,40 +7,18 @@ export type Lang = {
code: Intl.Locale["language"]; code: Intl.Locale["language"];
name: string; name: string;
flag: string; flag: string;
region: string; region?: Intl.Locale["region"];
}; };
export type LangCode = Lang["code"]; export type LangCode = Lang["code"];
function getFlagEmoji(regionCode: string): string { export const supportedLanguages: Lang[] = [
const A_LETTER_CODE = 0x1F1E6; { code: "de", name: "Deutsch", flag: "🇩🇪" },
const a_char_code = "A".charCodeAt(0); { code: "en", name: "English", flag: "🇺🇸" },
const codePoints = regionCode { code: "fi", name: "Suomi", flag: "🇫🇮" },
.toUpperCase() { code: "sv", name: "Svenska", flag: "🇸🇪" },
.split("")
.map((char) => A_LETTER_CODE + char.charCodeAt(0) - a_char_code);
return String.fromCodePoint(...codePoints);
}
const languageDefinitions: Partial<Lang>[] = [
{ code: "de", name: "Deutschland" },
{ code: "en", name: "English", region: "us" },
{ code: "fi", name: "Suomi" },
{ code: "sv", name: "Svenska" },
]; ];
export const supportedLanguages: Lang[] = languageDefinitions.map(
({ code, name, region }) => {
const regionCode = region ?? code;
return {
code,
name,
region: regionCode.toUpperCase(),
flag: getFlagEmoji(regionCode),
};
},
);
export const FALLBACK_LANGUAGE_CODE: LangCode = "en"; export const FALLBACK_LANGUAGE_CODE: LangCode = "en";
i18next i18next

1
vite.config.ts

@ -1,6 +1,5 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa";
import { viteStaticCopy } from "vite-plugin-static-copy"; import { viteStaticCopy } from "vite-plugin-static-copy";
import { execSync } from "node:child_process"; import { execSync } from "node:child_process";
import process from "node:process"; import process from "node:process";

Loading…
Cancel
Save