Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(locale): add en_HK locale #2083

Merged
merged 8 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guide/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ In this example there are 5 locales. Each of these is checked in order, and the
| `en_CA` | English (Canada) | `fakerEN_CA` |
| `en_GB` | English (Great Britain) | `fakerEN_GB` |
| `en_GH` | English (Ghana) | `fakerEN_GH` |
| `en_HK` | English (Hong Kong) | `fakerEN_HK` |
| `en_IE` | English (Ireland) | `fakerEN_IE` |
| `en_IN` | English (India) | `fakerEN_IN` |
| `en_NG` | English (Nigeria) | `fakerEN_NG` |
Expand Down
16 changes: 4 additions & 12 deletions docs/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,12 @@ fakerES.music.songName(); // 'I Want to Hold Your Hand' (fallback from en)
fakerES_noFallbacks.music.songName(); // throws a FakerError
```

This also has an impact on data that aren't applicable to a locale, for example Chinese doesn't use prefixes in names.
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.

```ts
import { faker, fakerZH_CN, zh_CN } from '@faker-js/faker';

const fakerZH_CN_noFallbacks = new Faker({
locale: [zh_CN],
});

faker.name.prefix(); // 'Mr'
// Previously:
//fakerZH_CN_noFallbacks.person.prefix(); // undefined
// Now:
fakerZH_CN.person.prefix(); // throws a FakerError
import { fakerEN_US, fakerEN_HK } from '@faker-js/faker';
fakerEN_US.location.zipCode(); // 90210
fakerEN_HK.location.zipCode(); // throws a FakerError
```

### `faker.mersenne` and `faker.helpers.repeatString` removed
Expand Down
13 changes: 13 additions & 0 deletions src/locale/en_HK.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/

import { Faker } from '../faker';
import base from '../locales/base';
import en from '../locales/en';
import en_HK from '../locales/en_HK';

export const faker = new Faker({
locale: [en_HK, en, base],
});
3 changes: 3 additions & 0 deletions src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { faker as fakerEN_BORK } from './en_BORK';
import { faker as fakerEN_CA } from './en_CA';
import { faker as fakerEN_GB } from './en_GB';
import { faker as fakerEN_GH } from './en_GH';
import { faker as fakerEN_HK } from './en_HK';
import { faker as fakerEN_IE } from './en_IE';
import { faker as fakerEN_IN } from './en_IN';
import { faker as fakerEN_NG } from './en_NG';
Expand Down Expand Up @@ -84,6 +85,7 @@ export {
fakerEN_CA,
fakerEN_GB,
fakerEN_GH,
fakerEN_HK,
fakerEN_IE,
fakerEN_IN,
fakerEN_NG,
Expand Down Expand Up @@ -149,6 +151,7 @@ export const allFakers = {
en_CA: fakerEN_CA,
en_GB: fakerEN_GB,
en_GH: fakerEN_GH,
en_HK: fakerEN_HK,
en_IE: fakerEN_IE,
en_IN: fakerEN_IN,
en_NG: fakerEN_NG,
Expand Down
12 changes: 12 additions & 0 deletions src/locales/en_HK/company/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { CompanyDefinitions } from '../../..';
import suffix from './suffix';

const company: CompanyDefinitions = {
suffix,
};

export default company;
1 change: 1 addition & 0 deletions src/locales/en_HK/company/suffix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Ltd.', 'Co. Ltd.'];
22 changes: 22 additions & 0 deletions src/locales/en_HK/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { LocaleDefinition } from '../..';
import company from './company';
import internet from './internet';
import location from './location';
import metadata from './metadata';
import person from './person';
import phone_number from './phone_number';

const en_HK: LocaleDefinition = {
company,
internet,
location,
metadata,
person,
phone_number,
};

export default en_HK;
1 change: 1 addition & 0 deletions src/locales/en_HK/internet/domain_suffix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['com', 'hk', 'com.hk', 'org.hk'];
12 changes: 12 additions & 0 deletions src/locales/en_HK/internet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { InternetDefinitions } from '../../..';
import domain_suffix from './domain_suffix';

const internet: InternetDefinitions = {
domain_suffix,
};

export default internet;
1 change: 1 addition & 0 deletions src/locales/en_HK/location/building_number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['###', '##', '#'];
106 changes: 106 additions & 0 deletions src/locales/en_HK/location/city.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
export default [
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Aberdeen',
'Ap Lei Chau',
'Causeway Bay',
'Chai Wan',
'Cheung Chau',
'Cheung Fat',
'Cheung Sha Wan',
'Choi Hung Chuen',
'Choi Ming',
'Chuk Yuen',
'Cyberport',
'Discovery Bay',
'Fairview Park',
'Fanling',
'Fo Tan',
'Fu Shan',
'Fu Shin',
'Fu Tai',
'Happy Valley',
'Heng Fa Chuen',
'Heng On',
'Hin Keng',
'Ho Man Tin',
'Hung Hom Bay',
'Kam Tai',
'Kam Tin',
'Kennedy Town',
'Kowloon',
'Kowloon Bay',
'Kowloon Central',
'Kowloon City',
'Kowloon East',
'Kwai Chung',
'Kwai Fong',
'Kwai Shing',
'Kwong Yuen',
'Kwun Tong',
'Lai King',
'Lai Kok',
'Lam Tin',
'Lamma',
'Lee On',
'Lei Muk Shue',
'Lei Tung',
'Leung King',
'Lok Fu',
'Ma On Shan',
'Mei Foo Sun Chuen',
'Mei Lam',
'Mong Kok',
'Mui Wo',
'Ngau Chi Wan',
'Ngau Tau Kok',
'Oi Man',
'Peak',
'Peng Chau',
'Po Lam',
'Pok Fu Lam',
'Repulse Bay',
'Sai Kung',
'Sai Ying Pun',
'San Tin',
'Sau Mau Ping',
'Sha Kok',
'Sha Tau Kok',
'Sha Tin',
'Sham Shui Po',
'Shau Kei Wan',
'Shek Kip Mei',
'Shek Lei',
'Shek Wai Kok',
'Shek Wu Hui',
'Sheung Tak',
'Sheung Wan',
'Shun Lee',
'Siu Sai Wan',
'So Uk',
'Stanley',
'Sun Chui',
'Tai Hing',
'Tai Kok Tsui',
'Tai Koo Shing',
'Tai O',
'Tai Po',
'Tin Yiu',
'Tin Yuet',
'To Kwa Wan',
'Tsat Tsz Mui',
'Tseung Kwan O',
'Tsim Sha Tsui',
'Tsing Yi',
'Tsuen Wan',
'Tsz Wan Shan',
'Tuen Mun',
'Tung Chung',
'Wah Fu',
'Wah Ming',
'Wan Chai',
'Wan Tau Tong',
'Wo Che',
'Wong Tai Sin',
'Yau Tong',
'Yau Yat Tsuen',
'Yuen Long',
];
1 change: 1 addition & 0 deletions src/locales/en_HK/location/default_country.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Hong Kong'];
34 changes: 34 additions & 0 deletions src/locales/en_HK/location/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { LocationDefinitions } from '../../..';
import building_number from './building_number';
import city from './city';
import default_country from './default_country';
import postcode from './postcode';
import postcode_by_state from './postcode_by_state';
import state from './state';
import state_abbr from './state_abbr';
import street_cantonese_part from './street_cantonese_part';
import street_english_part from './street_english_part';
import street_pattern from './street_pattern';
import street_prefix from './street_prefix';
import street_suffix from './street_suffix';

const location: LocationDefinitions = {
building_number,
city,
default_country,
postcode,
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
postcode_by_state,
state,
state_abbr,
street_cantonese_part,
street_english_part,
street_pattern,
street_prefix,
street_suffix,
};

export default location;
2 changes: 2 additions & 0 deletions src/locales/en_HK/location/postcode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://www.hongkongpost.hk/en/about_us/tips/postcode/index.html
export default null;
2 changes: 2 additions & 0 deletions src/locales/en_HK/location/postcode_by_state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://www.hongkongpost.hk/en/about_us/tips/postcode/index.html
export default null;
1 change: 1 addition & 0 deletions src/locales/en_HK/location/state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Hong Kong Island', 'Kowloon', 'New Territories'];
1 change: 1 addition & 0 deletions src/locales/en_HK/location/state_abbr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['HK', 'KLN', 'NT'];
80 changes: 80 additions & 0 deletions src/locales/en_HK/location/street_cantonese_part.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
export default [
'Wan',
'On',
'Tai',
'Man',
'Fung',
'Cheung',
'Tung',
'Hing',
'Po',
'Wah',
'Tak',
'Shing',
'Lung',
'Yuen',
'Wing',
'Hong',
'Yip',
'King',
'Kwong',
'Hoi',
'Ming',
'Wa',
'Lok',
'Yan',
'Wai',
'Chi',
'Fuk',
'Lai',
'Lee',
'Fu',
'Tin',
'Kai',
'Sai',
'Shun',
'Ping',
'Yee',
'Wo',
'Chung',
'Hang',
'Ning',
'Wong',
'Yue',
'Choi',
'Wang',
'Ching',
'Sau',
'Shan',
'Tsui',
'Tau',
'Sheung',
'Lam',
'Fat',
'Hung',
'Chuk',
'Shek',
'Kok',
'Cheong',
'Fong',
'Nam',
'Lei',
'Yu',
'Mei',
'Pak',
'Fai',
'Kwai',
'Sing',
'Kung',
'Chau',
'Tong',
'San',
'Chiu',
'Chun',
'Yin',
'Yuk',
'Ting',
'Kam',
'Lun',
'Oi',
];
Loading