-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(locale): add counties & states to nb_NO location #3617
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
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
xDivisionByZerox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR @jylep.
I see in the PR description that your intend was to add "top-level administrative" for Norway. I can see in the linked sources that this administrative level is called "county" in Norway. So I can see why you would put them into the "county.ts" file.
Please take a look at the descriptions of the county and state property in the location definition:
faker/src/definitions/location.ts
Lines 55 to 58 in b547045
/** * The names of this country's states, or other first-level administrative areas. */ state: string[]; faker/src/definitions/location.ts
Lines 65 to 68 in b547045
/** * The names of counties, or other second-level administrative areas, inside the country's states. */ county: string[];
As you can see state represents the first-level administrative areas while county represents the second-level administrative areas. This has sadly been the case for quite some time due to the historic nature of the project heavily defaulting to the US state for structuring locale data sets.
After reading on the administrative divisions of Norway I would suggest putting the Norwegen "counties" (fylker) into Fakers "state" (first-level) property, while the Norwegen "municipalities" (kommune) would match Fakers "county" (second-level) property.
I can see that this might cause confusion due to the naming collision between Fakers naming definition and the real words application of these words. But, I'd say it is much better in the long run, to stay consistent and honor the specification of a fields when adding locale data to it. I can see the names of these entries change in the future to a more generic term, as we had this exact problem multiple times now.
Please tell me your opinion on the matter and thank you again for taking the initiative and time to making Faker better for anyone by providing these locale data.
|
I tend to agree. For consistency let's put 1at level admin areas in state() and 2nd level in county() regardless of the official name. |
|
Added kommuner (municipalities) as well for counties. 👍 |
|
The test seem to be failing for multiple reasons:
To solve problem 1, it should be enough to regenerate the locales via the npm script pnpm run generate:locales
# OR
npm run generate:localesFor the second problem you need to run the test with the pnpm run test:update-snapshots
# OR
npm run test:update-snapshotsThe third problem can be solved by running the formatter locally: pnpm run format
# OR
npm run format@jylep Would you be so kind and run these scripts on your locale setup and commit the resulting changes afterwards? After that, the tests should be fixed. |
|
I tried to run tests locally to see what is causing the failing tests but I got way more errors that are likely unrelated (dynamic import errors) The CI logs are not really giving me any info on what could be wrong. Just in case I ran the |
|
Dynamic import errors suggest you may be using an old version of node. Faker.js v10 requires a minimum of Node.js v20.19.0, v22.13.0, or v24.0.0. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3617 +/- ##
========================================
Coverage 99.97% 99.97%
========================================
Files 2960 2961 +1
Lines 234711 235086 +375
Branches 932 930 -2
========================================
+ Hits 234658 235033 +375
Misses 53 53
🚀 New features to boost your workflow:
|
Adding missing top-level administrative equivalent of states for Norwegian locale (fylker)
https://en.wikipedia.org/wiki/Counties_of_Norway