/** * Get the string for the passed language from a dictionary object. * * TODO: Make this clever. Currently a simple key look-up, but should use * BCP-47 mapping so that e.g. `en-US` returns `en` strings, and use the * site’s default locale as a last resort. * * @example * pickLang({ en: 'Hello', fr: 'Bonjour' }, 'en'); // => 'Hello' */ export function pickLang>( dictionary: T, lang: keyof T ): string | undefined { return dictionary[lang]; }