From bd09a0d07cd9a9d9b859d3957df5cbb0b2e47bd5 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Wed, 31 May 2023 20:42:16 +0900 Subject: [PATCH 1/7] feat(local): add street for ja Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/locales/ja/location/index.ts | 4 ++++ src/locales/ja/location/secondary_address.ts | 1 + src/locales/ja/location/street_address.ts | 4 ++++ src/locales/ja/location/street_pattern.ts | 5 +---- src/modules/location/index.ts | 11 +++++++---- 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/locales/ja/location/secondary_address.ts create mode 100644 src/locales/ja/location/street_address.ts diff --git a/src/locales/ja/location/index.ts b/src/locales/ja/location/index.ts index a4dfdd5567a..6f1f6f4d499 100644 --- a/src/locales/ja/location/index.ts +++ b/src/locales/ja/location/index.ts @@ -8,8 +8,10 @@ import city_prefix from './city_prefix'; import city_suffix from './city_suffix'; import country from './country'; import postcode from './postcode'; +import secondary_address from './secondary_address'; import state from './state'; import state_abbr from './state_abbr'; +import street_address from './street_address'; import street_pattern from './street_pattern'; const location: LocationDefinition = { @@ -20,6 +22,8 @@ const location: LocationDefinition = { postcode, state, state_abbr, + secondary_address, + street_address, street_pattern, }; diff --git a/src/locales/ja/location/secondary_address.ts b/src/locales/ja/location/secondary_address.ts new file mode 100644 index 00000000000..2146358ca5d --- /dev/null +++ b/src/locales/ja/location/secondary_address.ts @@ -0,0 +1 @@ +export default ['{{person.last_name}}###号室']; diff --git a/src/locales/ja/location/street_address.ts b/src/locales/ja/location/street_address.ts new file mode 100644 index 00000000000..296fae5657c --- /dev/null +++ b/src/locales/ja/location/street_address.ts @@ -0,0 +1,4 @@ +export default { + normal: '{{location.street}}', + full: '{{location.street}} {{location.secondaryAddress}}', +}; diff --git a/src/locales/ja/location/street_pattern.ts b/src/locales/ja/location/street_pattern.ts index 06ca3a5e812..52a7ef7bbe8 100644 --- a/src/locales/ja/location/street_pattern.ts +++ b/src/locales/ja/location/street_pattern.ts @@ -1,4 +1 @@ -export default [ - '{{person.first_name}}{{location.street_suffix}}', - '{{person.last_name}}{{location.street_suffix}}', -]; +export default ['#丁目#番#号']; diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 7feb96ee536..a70c006eee5 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -207,9 +207,11 @@ export class LocationModule { * @since 8.0.0 */ street(): string { - return this.faker.helpers.fake( + const format = this.faker.helpers.fake( this.faker.definitions.location.street_pattern ); + + return this.faker.helpers.replaceSymbols(format); } /** @@ -267,11 +269,12 @@ export class LocationModule { } const { useFullAddress } = options; - const formats = this.faker.definitions.location.street_address; - const format = formats[useFullAddress ? 'full' : 'normal']; + let format = formats[useFullAddress ? 'full' : 'normal']; + + format = this.faker.helpers.fake(format); - return this.faker.helpers.fake(format); + return this.faker.helpers.replaceSymbols(format); } /** From 18ecd9d04bed1ec326ee520845daba7c5f5c1648 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Thu, 1 Jun 2023 10:23:57 +0900 Subject: [PATCH 2/7] fix(locale): use mustash number.int for ja street address Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/locales/ja/location/street_pattern.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/locales/ja/location/street_pattern.ts b/src/locales/ja/location/street_pattern.ts index 52a7ef7bbe8..693c8b97a4b 100644 --- a/src/locales/ja/location/street_pattern.ts +++ b/src/locales/ja/location/street_pattern.ts @@ -1 +1,3 @@ -export default ['#丁目#番#号']; +export default [ + '{{number.int({"max": 10, "min": 1})}}丁目{{number.int({"max": 10, "min": 1})}}番{{number.int({"max": 10, "min": 1})}}号', +]; From f2ca178ef7625ae79d3e2bbe0b71da5a175818c6 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Thu, 1 Jun 2023 10:26:06 +0900 Subject: [PATCH 3/7] fix(locale): revert replace symbols addition for street APIs Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/modules/location/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index a70c006eee5..7feb96ee536 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -207,11 +207,9 @@ export class LocationModule { * @since 8.0.0 */ street(): string { - const format = this.faker.helpers.fake( + return this.faker.helpers.fake( this.faker.definitions.location.street_pattern ); - - return this.faker.helpers.replaceSymbols(format); } /** @@ -269,12 +267,11 @@ export class LocationModule { } const { useFullAddress } = options; - const formats = this.faker.definitions.location.street_address; - let format = formats[useFullAddress ? 'full' : 'normal']; - format = this.faker.helpers.fake(format); + const formats = this.faker.definitions.location.street_address; + const format = formats[useFullAddress ? 'full' : 'normal']; - return this.faker.helpers.replaceSymbols(format); + return this.faker.helpers.fake(format); } /** From a83f75ac4f942ae362568294c4eb9f69ecd62551 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Thu, 1 Jun 2023 10:29:16 +0900 Subject: [PATCH 4/7] fix(locale): run pnpm run preflight Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/locales/ja/location/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/ja/location/index.ts b/src/locales/ja/location/index.ts index 6f1f6f4d499..2c66e01507a 100644 --- a/src/locales/ja/location/index.ts +++ b/src/locales/ja/location/index.ts @@ -20,9 +20,9 @@ const location: LocationDefinition = { city_suffix, country, postcode, + secondary_address, state, state_abbr, - secondary_address, street_address, street_pattern, }; From 93995ded03588e9fbd09282bfb2afdde01b34985 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Thu, 1 Jun 2023 11:32:25 +0900 Subject: [PATCH 5/7] =?UTF-8?q?fix(locale):=20max=20to=209=20for=20?= =?UTF-8?q?=E4=B8=81=E7=9B=AE,=E7=95=AA=E5=9C=B0=20and=20=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/locales/ja/location/street_pattern.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/ja/location/street_pattern.ts b/src/locales/ja/location/street_pattern.ts index 693c8b97a4b..b4c3046377f 100644 --- a/src/locales/ja/location/street_pattern.ts +++ b/src/locales/ja/location/street_pattern.ts @@ -1,3 +1,3 @@ export default [ - '{{number.int({"max": 10, "min": 1})}}丁目{{number.int({"max": 10, "min": 1})}}番{{number.int({"max": 10, "min": 1})}}号', + '{{number.int({"max": 9, "min": 1})}}丁目{{number.int({"max": 9, "min": 1})}}番{{number.int({"max": 9, "min": 1})}}号', ]; From 3d5a846779c95ddd72c98b896ece1142a6c1eaca Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Fri, 2 Jun 2023 14:06:19 +0900 Subject: [PATCH 6/7] fix(locale): add missing secondard address mustash parsing Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/modules/location/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 7feb96ee536..da1e5815e86 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -284,7 +284,7 @@ export class LocationModule { * @since 8.0.0 */ secondaryAddress(): string { - return this.faker.helpers + const format = this.faker.helpers .arrayElement(this.faker.definitions.location.secondary_address) .replace(/#+/g, (m) => this.faker.string.numeric({ @@ -292,6 +292,8 @@ export class LocationModule { allowLeadingZeros: false, }) ); + + return this.faker.helpers.fake(format); } /** From b5dafe978c13802297d7880fdc2206891ad09eae Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Mon, 5 Jun 2023 07:05:19 +0900 Subject: [PATCH 7/7] Update src/modules/location/index.ts Co-authored-by: ST-DDT --- src/modules/location/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index da1e5815e86..f7b001033a5 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -284,16 +284,14 @@ export class LocationModule { * @since 8.0.0 */ secondaryAddress(): string { - const format = this.faker.helpers - .arrayElement(this.faker.definitions.location.secondary_address) + return this.faker.helpers + .fake(this.faker.definitions.location.secondary_address) .replace(/#+/g, (m) => this.faker.string.numeric({ length: m.length, allowLeadingZeros: false, }) ); - - return this.faker.helpers.fake(format); } /**