TypeScript
/@infobits/intl

Drapeaux

Drapeaux

Le package inclut 256 drapeaux SVG de pays, minifies et integres sous forme de chaines de caracteres. Les drapeaux sont indexes par les codes pays ISO 3166-1 alpha-2.

Drapeaux SVG

Obtenir un drapeau par code pays

GoDartTypeScript
import { getFlag, flags } from 'infobits-intl';

// Using the lookup function
const svg = getFlag('US');

// Or access the map directly
const svgDirect = flags['US'];

Afficher les drapeaux SVG

Les chaines SVG peuvent etre utilisees directement dans votre application :

GoDartTypeScript
import { getFlag } from 'infobits-intl';

// In a web application
const svg = getFlag('NO');
if (svg) {
  document.getElementById('flag-container')!.innerHTML = svg;
}

Drapeaux emoji

Les drapeaux emoji sont generes a partir des codes pays en utilisant les symboles indicateurs regionaux.

GoDartTypeScript
import { getEmojiFlag } from 'infobits-intl';

console.log(getEmojiFlag('US'));
console.log(getEmojiFlag('NO'));

Drapeaux de langues

Les langues peuvent avoir un drapeau representatif via leur defaultFlagCode.

GoDartTypeScript
import { getLanguageByCode, getFlag } from 'infobits-intl';

const lang = getLanguageByCode('fr');
if (lang?.defaultFlagCode) {
  const svg = getFlag(lang.defaultFlagCode);
}

Tous les drapeaux disponibles

Parcourir tous les drapeaux disponibles :

GoDartTypeScript
import { flags } from 'infobits-intl';

for (const [code, svg] of Object.entries(flags)) {
  console.log(`${code}: ${svg.length} bytes`);
}