Skip to content

Commit

Permalink
docs(README): add example typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoDanin committed May 24, 2020
1 parent f40a5d0 commit 541d0eb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
58 changes: 40 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
# Locale Codes

[![Travis](https://img.shields.io/travis/TiagoDanin/Locale-Codes.svg?branch=master&style=flat-square)](https://travis-ci.org/TiagoDanin/Locale-Codes) [![Downloads](https://img.shields.io/npm/dt/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes) [![Node](https://img.shields.io/node/v/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes) [![Version](https://img.shields.io/npm/v/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes)
[![Travis](https://img.shields.io/travis/TiagoDanin/Locale-Codes.svg?branch=master&style=flat-square)](https://travis-ci.org/TiagoDanin/Locale-Codes) [![Downloads](https://img.shields.io/npm/dt/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes) [![Node](https://img.shields.io/node/v/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes) [![Version](https://img.shields.io/npm/v/locale-codes.svg?style=flat-square)](https://npmjs.org/package/locale-codes) [![XO code style](https://img.shields.io/badge/code%20style-XO-red.svg?style=flat-square)](https://github.com/xojs/xo)

Language codes & country codes

## Installation

Module available through the [npm registry](https://www.npmjs.com/). It can be installed using the [`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally) or [`yarn`](https://yarnpkg.com/en/) command line tools.
Module available through the [npm registry](https://www.npmjs.com/). It can be installed using the [`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally) or [`yarn`](https://yarnpkg.com/en/) command line tool.

```sh
# NPM
npm install locale-codes --save
# Or Using Yarn
# Yarn (Recomend)
yarn add locale-codes
# NPM
npm install locale-codes --save
```

## Example
## Examples

### JavaScript

```js
/* eslint-disable no-unused-expressions */
const locale = require('locale-codes')

locale.all // [language: '...]
locale.all // [language: '...']
locale.getByTag('pt-br').name // 'Portuguese'
locale.where('tag', 'pt-br').name // 'Portuguese'
```

Or in Typescript:
### TypeScript

```typescript
import * as LocaleCodes from "locale-codes";
```ts
/* eslint-disable @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unused-vars */
import * as locale from 'locale-codes'
import {ILocale} from '.'

LocaleCodes.all // ILocale[]
LocaleCodes.getByTag('pt-br').name // 'Portuguese'
locale.all // [language: '...']
const localeSelect: ILocale = locale.all[0]

locale.getByTag('pt-br').name // 'Portuguese'
locale.where('tag', 'pt-br').name // 'Portuguese'
```

## Documentation
Expand Down Expand Up @@ -889,9 +898,7 @@ Zulu | isiZulu | South Africa | zu-ZA | 1077 | zul | zu |
To run the test suite, first install the dependencies, then run `test`:

```sh
# NPM
npm test
# Or Using Yarn
# Using Yarn
yarn test
```

Expand All @@ -903,17 +910,32 @@ yarn test
<b>License</b>: MIT</br>
<b>Version</b>: ^1.0.1
</details>
<details>
<summary><a href="https://ghub.io/langs">langs</a>: ISO 639-1/2/3 Language codes with English and local names</summary>
<b>Author</b>: adlawson</br>
<b>License</b>: MIT</br>
<b>Version</b>: ^2.0.0
</details>
<details>
<summary><a href="https://ghub.io/windows-locale">windows-locale</a>: Windows Language Code Identifier (LCID) for JavaScript</summary>
<b>Author</b>: Tiago Danin</br>
<b>License</b>: MIT</br>
<b>Version</b>: ^1.0.1
</details>

## Dev Dependencies

<details>
<summary><a href="https://ghub.io/langs">langs</a>: ISO 639-1/2/3 Language codes with English and local names</summary>
<b>Author</b>: adlawson</br>
<summary><a href="https://ghub.io/tsd">tsd</a>: Check TypeScript type definitions</summary>
<b>Author</b>: Sam Verschueren</br>
<b>License</b>: MIT</br>
<b>Version</b>: ^2.0.0
<b>Version</b>: ^0.11.0
</details>
<details>
<summary><a href="https://ghub.io/xo">xo</a>: JavaScript/TypeScript linter with great defaults</summary>
<b>Author</b>: Sindre Sorhus</br>
<b>License</b>: MIT</br>
<b>Version</b>: ^0.30.0
</details>

## Contributors
Expand Down
1 change: 1 addition & 0 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ const locale = require('.')

locale.all // [language: '...']
locale.getByTag('pt-br').name // 'Portuguese'
locale.where('tag', 'pt-br').name // 'Portuguese'
9 changes: 9 additions & 0 deletions example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unused-vars */
import * as locale from '.'
import {ILocale} from '.'

locale.all // [language: '...']
const localeSelect: ILocale = locale.all[0]

locale.getByTag('pt-br').name // 'Portuguese'
locale.where('tag', 'pt-br').name // 'Portuguese'

0 comments on commit 541d0eb

Please sign in to comment.