Skip to content

Instantly share code, notes, and snippets.

View jhannes's full-sized avatar

Johannes Brodwall jhannes

View GitHub Profile
@jhannes
jhannes / LocalizationDemo.tsx
Created June 24, 2021 20:07
TypeScript localization
import React, { useContext, useState } from "react";
import { BrowserRouter, Link } from "react-router-dom";
import { Route, Switch } from "react-router";
import { format, formatDistance, formatRelative } from "date-fns";
import nb from "date-fns/locale/nb";
import enUS from "date-fns/locale/en-US";
type AppLocale = "en" | "nb";
interface ApplicationTexts extends Record<AppLocale, string> {