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): support street and street address for ja #2193

Merged
merged 12 commits into from
Apr 6, 2024
Merged
4 changes: 4 additions & 0 deletions src/locales/ja/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -20,6 +22,8 @@ const location: LocationDefinition = {
postcode,
state,
state_abbr,
secondary_address,
street_address,
street_pattern,
};

Expand Down
1 change: 1 addition & 0 deletions src/locales/ja/location/secondary_address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['{{person.last_name}}###号室'];
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions src/locales/ja/location/street_address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
normal: '{{location.street}}',
full: '{{location.street}} {{location.secondaryAddress}}',
};
5 changes: 1 addition & 4 deletions src/locales/ja/location/street_pattern.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
export default [
'{{person.first_name}}{{location.street_suffix}}',
'{{person.last_name}}{{location.street_suffix}}',
];
export default ['#丁目#番#号'];
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 7 additions & 4 deletions src/modules/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down