Skip to content

Commit 0ca2f51

Browse files
committed
feat: Setting default language
1 parent 86e57e1 commit 0ca2f51

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ npm i @paunovic/random-words
1919
```js
2020
import { initialize } from '@paunovic/random-words'
2121

22-
// Default language pack
22+
// Initialization with default language pack
23+
const RANDOM = initialize();
24+
25+
// Initialization with different language pack
2326
const RANDOM = initialize({ countryCode: 'rs' })
2427

25-
// With variation
28+
// Initialization with different language pack, including variation
2629
const RANDOM = initialize({ countryCode: 'rs', variation: 'cyrillic' })
2730
```
2831

@@ -31,9 +34,11 @@ Currently available country codes and variations:
3134
| Country | Country code | Variation |
3235
| :------------ | :----------: | :--------: |
3336
| Serbia | `rs` | `cyrillic` |
34-
| United States | `us` | |
37+
| United States `*` | `us` | |
3538
| Spain | `es` | |
3639

40+
`*` Default language; if no `countryCode` parameter is passed to `initialize` method, english will be loaded as a default language.
41+
3742
## Methods
3843

3944
```js

lib/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import { randomNumber } from './helpers/general.js';
1616
*
1717
*/
1818

19-
export const initialize = ({ countryCode, variation = 'default' }) => {
20-
if (!countryCode) throw new Error('Missing parameter countryCode.');
21-
19+
export const initialize = ({ countryCode = 'us', variation = 'default' }) => {
2220
const WORDS = LANGUAGES[countryCode][variation];
2321

2422
/**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paunovic/random-words",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"type": "module",
55
"description": "Serving random words in any language has never been this easy.",
66
"author": {

0 commit comments

Comments
 (0)