Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
1.1 kB · 36 lines
TSX
123456789101112131415161718192021222324252627282930313233343536import type React from "react";import TsCountryFlag from "ts-react-emoji-flag";
const userLocale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
const getCountryNamesIntl = new Intl.DisplayNames([userLocale ?? 'en'], { type: 'region' });
export const getCountryName = (iso2: string) => { const name = getCountryNamesIntl.of(iso2); if (name !== undefined) { return name; } return iso2;}
export const CountryFlag = (props: { iso: string, tooltip?: true | string | ((country: string) => string)}) => { const isoToUse = props.iso === 'XW' ? 'UN' : props.iso;
let content: string | undefined = undefined;; if (props.tooltip !== undefined) { if (props.tooltip === true) { content = getCountryName(props.iso); } else if (typeof props.tooltip === 'function') { content = props.tooltip(getCountryName(props.iso)) } else { content = props.tooltip; } } return <TsCountryFlag countryCode={isoToUse} title={content}/>;}