Skip to content

BRIXTOL/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@brixtol/i18n

Static GeoIP utilities which accepts a 3166-1 alpha-2 country code and returns a JSON object with relevant Geographical information.

Why?

The vast majority of GeoIP services were doing too much or too little. We wanted a basic static powered GeoIP that would return exactly what we required in a fast and efficient manner. This project is composed from a series of small packages that map information from a series of datasets.

Install

pnpm

pnpm add @brixtol/i18n

npm

npm install @brixtol/i18n

Yarn

yarn add @brixtol/i18n

Usage

Pass in a currency code that is lowercase, uppercase or a mixture of both. There is 1 export available, the i18n function exposes a mutate option. When true is passed then the function is curried. If you do not need to mutate the default response is returned.

Response

The i18n response will return the following response (locale) information:

interface IGeoIP {
  /**
   * The 2 Letter country code
   */
  countryCode: string;
  /**
   * The Country Name (in English)
   */
  countryName: string;
  /**
   * The 3 letter Currency Code
   */
  currencyCode: string;
  /**
   * The Currency Symbol
   */
  currencySymbol: string;
  /**
   * The Currency Placement
   */
  currencyPlacement: string;
}

Example

import { i18n } from '@brixtol/i18n';

const default = geo('NL')
// => IGeoIP

const mutator = i18n('NL', { mutate: true})(locale => ({ ...locale, hello: 'hoi!' }))
// => IGeoIP & { hello: 'hoi!' }

Packages

This module constructs the response by using the following smaller modules:

License

Licensed under MIT


We ♡ open source!