-
-
Notifications
You must be signed in to change notification settings - Fork 929
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: use street address templates from locales #754
Conversation
Codecov Report
@@ Coverage Diff @@
## main #754 +/- ##
=======================================
Coverage 99.34% 99.34%
=======================================
Files 1921 1921
Lines 176540 176628 +88
Branches 908 906 -2
=======================================
+ Hits 175387 175475 +88
Misses 1097 1097
Partials 56 56
|
Depends on #756 |
#756 was merged |
I converted the street_address templates using the following script: function updateLocaleFileHook(
filePath: string,
locale: string,
localePath: string[]
): void {
if (localePath[0] === 'address' && localePath[1] === 'street_address') {
console.log(filePath + ' <-> ' + locale + ' @ ' + localePath.join(' -> '));
let content: string[] = require(filePath).default.map((entry) =>
entry
.replace('#{street_name}', '{{address.streetName}}')
.replace('#{address.street_name}', '{{address.streetName}}')
.replace('#{building_number}', '{{address.buildingNumber}}')
.replace('#{address.building_number}', '{{address.buildingNumber}}')
.replace('#{secondary_address}', '{{address.secondaryAddress}}')
);
content = [
content[0].replace(' {{address.secondaryAddress}}', '').replace(/,$/, ''),
content[1] ??
content[0].replace(' {{address.secondaryAddress}}', '') +
' {{address.secondaryAddress}}',
];
let fileContent =
'export default ' + JSON.stringify(content) + ' as [string, string]';
fileContent = format(fileContent, prettierTsOptions);
console.log(fileContent);
writeFileSync(filePath, fileContent);
}
} During the implementation I noticed, that some locale files contained two patterns, one with the normal pattern and one with the full pattern. I'm not sure whether |
Here are some examples for the generated addresses: (click to expand)
|
Polish one ( |
I could change/fix the format here, but it might be best if you create a separate PR for that (format/street address, street name, building number and secondary address) |
Like this? |
Adds #88
faker.address.buildingNumber()
faker.address.streetAddress()
to use the templates from the localesfake()
format