Skip to content

Commit 698fd7d

Browse files
authored
feat(locale): add en_HK locale (#2083)
1 parent 76c3080 commit 698fd7d

31 files changed

Lines changed: 530 additions & 12 deletions

docs/guide/localization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ In this example there are 5 locales. Each of these is checked in order, and the
9191
| `en_CA` | English (Canada) | `fakerEN_CA` |
9292
| `en_GB` | English (Great Britain) | `fakerEN_GB` |
9393
| `en_GH` | English (Ghana) | `fakerEN_GH` |
94+
| `en_HK` | English (Hong Kong) | `fakerEN_HK` |
9495
| `en_IE` | English (Ireland) | `fakerEN_IE` |
9596
| `en_IN` | English (India) | `fakerEN_IN` |
9697
| `en_NG` | English (Nigeria) | `fakerEN_NG` |

docs/guide/upgrading.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,12 @@ fakerES.music.songName(); // 'I Want to Hold Your Hand' (fallback from en)
123123
fakerES_noFallbacks.music.songName(); // throws a FakerError
124124
```
125125

126-
This also has an impact on data that aren't applicable to a locale, for example Chinese doesn't use prefixes in names.
126+
This also has an impact on data that aren't applicable to a locale, for example Hong Kong (`en_HK`) doesn't use ZIP codes/postcodes.
127127

128128
```ts
129-
import { faker, fakerZH_CN, zh_CN } from '@faker-js/faker';
130-
131-
const fakerZH_CN_noFallbacks = new Faker({
132-
locale: [zh_CN],
133-
});
134-
135-
faker.name.prefix(); // 'Mr'
136-
// Previously:
137-
//fakerZH_CN_noFallbacks.person.prefix(); // undefined
138-
// Now:
139-
fakerZH_CN.person.prefix(); // throws a FakerError
129+
import { fakerEN_US, fakerEN_HK } from '@faker-js/faker';
130+
fakerEN_US.location.zipCode(); // 90210
131+
fakerEN_HK.location.zipCode(); // throws a FakerError
140132
```
141133

142134
### `faker.mersenne` and `faker.helpers.repeatString` removed

src/locale/en_HK.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
6+
import { Faker } from '../faker';
7+
import base from '../locales/base';
8+
import en from '../locales/en';
9+
import en_HK from '../locales/en_HK';
10+
11+
export const faker = new Faker({
12+
locale: [en_HK, en, base],
13+
});

src/locale/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { faker as fakerEN_BORK } from './en_BORK';
2020
import { faker as fakerEN_CA } from './en_CA';
2121
import { faker as fakerEN_GB } from './en_GB';
2222
import { faker as fakerEN_GH } from './en_GH';
23+
import { faker as fakerEN_HK } from './en_HK';
2324
import { faker as fakerEN_IE } from './en_IE';
2425
import { faker as fakerEN_IN } from './en_IN';
2526
import { faker as fakerEN_NG } from './en_NG';
@@ -84,6 +85,7 @@ export {
8485
fakerEN_CA,
8586
fakerEN_GB,
8687
fakerEN_GH,
88+
fakerEN_HK,
8789
fakerEN_IE,
8890
fakerEN_IN,
8991
fakerEN_NG,
@@ -149,6 +151,7 @@ export const allFakers = {
149151
en_CA: fakerEN_CA,
150152
en_GB: fakerEN_GB,
151153
en_GH: fakerEN_GH,
154+
en_HK: fakerEN_HK,
152155
en_IE: fakerEN_IE,
153156
en_IN: fakerEN_IN,
154157
en_NG: fakerEN_NG,

src/locales/en_HK/company/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
import type { CompanyDefinitions } from '../../..';
6+
import suffix from './suffix';
7+
8+
const company: CompanyDefinitions = {
9+
suffix,
10+
};
11+
12+
export default company;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default ['Ltd.', 'Co. Ltd.'];

src/locales/en_HK/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
import type { LocaleDefinition } from '../..';
6+
import company from './company';
7+
import internet from './internet';
8+
import location from './location';
9+
import metadata from './metadata';
10+
import person from './person';
11+
import phone_number from './phone_number';
12+
13+
const en_HK: LocaleDefinition = {
14+
company,
15+
internet,
16+
location,
17+
metadata,
18+
person,
19+
phone_number,
20+
};
21+
22+
export default en_HK;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default ['com', 'hk', 'com.hk', 'org.hk'];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
import type { InternetDefinitions } from '../../..';
6+
import domain_suffix from './domain_suffix';
7+
8+
const internet: InternetDefinitions = {
9+
domain_suffix,
10+
};
11+
12+
export default internet;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default ['###', '##', '#'];

0 commit comments

Comments
 (0)