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 directions and directions abbr to pl #1225

Merged
merged 8 commits into from Aug 19, 2022

Conversation

hankucz
Copy link
Contributor

@hankucz hankucz commented Aug 3, 2022

No description provided.

@hankucz hankucz requested a review from a team as a code owner August 3, 2022 19:08
@codecov
Copy link

codecov bot commented Aug 3, 2022

Codecov Report

Merging #1225 (67d11d8) into main (5585869) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 67d11d8 differs from pull request most recent head 1fefd2d. Consider uploading reports for the commit 1fefd2d to get more accurate results

@@            Coverage Diff             @@
##             main    #1225      +/-   ##
==========================================
+ Coverage   99.62%   99.63%   +0.01%     
==========================================
  Files        2154     2156       +2     
  Lines      239914   239940      +26     
  Branches     1003     1008       +5     
==========================================
+ Hits       239015   239066      +51     
+ Misses        878      853      -25     
  Partials       21       21              
Impacted Files Coverage Δ
src/locales/pl/address/direction.ts 100.00% <100.00%> (ø)
src/locales/pl/address/direction_abbr.ts 100.00% <100.00%> (ø)
src/locales/pl/address/index.ts 100.00% <100.00%> (ø)
src/modules/internet/user-agent.ts 88.35% <0.00%> (+6.61%) ⬆️

@import-brain import-brain requested a review from a team August 3, 2022 19:20
@import-brain import-brain added the c: locale Permutes locale definitions label Aug 3, 2022
@import-brain import-brain added this to the v7 - Current Major milestone Aug 3, 2022
import-brain
import-brain previously approved these changes Aug 3, 2022
Copy link
Member

@import-brain import-brain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations verified using Google Translate, lgtm

src/locales/pl/address/direction.ts Outdated Show resolved Hide resolved
src/locales/pl/address/direction_abbr.ts Outdated Show resolved Hide resolved
pkuczynski
pkuczynski previously approved these changes Aug 3, 2022
import-brain
import-brain previously approved these changes Aug 3, 2022
@pkuczynski pkuczynski changed the title feat(locales.pl): add pl translation for directions and directions abbr feat(locales.pl): add directions and directions abbr Aug 3, 2022
Copy link
Member

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of the elements is somewhat important:

/**
* Returns a random cardinal direction (north, east, south, west).
*
* @param useAbbr If true this will return abbreviated directions (N, E, etc).
* Otherwise this will return the long name. Defaults to `false`.
*
* @example
* faker.address.cardinalDirection() // 'North'
* faker.address.cardinalDirection(false) // 'South'
* faker.address.cardinalDirection(true) // 'N'
*/
cardinalDirection(useAbbr: boolean = false): string {
if (!useAbbr) {
return this.faker.helpers.arrayElement(
this.faker.definitions.address.direction.slice(0, 4)
);
}
return this.faker.helpers.arrayElement(
this.faker.definitions.address.direction_abbr.slice(0, 4)
);
}
/**
* Returns a random ordinal direction (northwest, southeast, etc).
*
* @param useAbbr If true this will return abbreviated directions (NW, SE, etc).
* Otherwise this will return the long name. Defaults to `false`.
*
* @example
* faker.address.ordinalDirection() // 'Northeast'
* faker.address.ordinalDirection(false) // 'Northwest'
* faker.address.ordinalDirection(true) // 'NE'
*/
ordinalDirection(useAbbr: boolean = false): string {
if (!useAbbr) {
return this.faker.helpers.arrayElement(
this.faker.definitions.address.direction.slice(4, 8)
);
}
return this.faker.helpers.arrayElement(
this.faker.definitions.address.direction_abbr.slice(4, 8)
);
}

0-3 => cardinal direction
4-7 => ordinal direction

@pkuczynski
Copy link
Member

pkuczynski commented Aug 3, 2022

Wow! I would never expect this and it's really hard to catch on the review. It would be way better if TS could catch it automatically...

Should we change the definition to look more like:

interface Directions {
  cardinal: string[]
  ordinal: string[] // or intercardinal ?
  secondaryIntercardinal?: string[]
}

type DirectionType = keyof Directions

And then both directions and directions_abbr should use this type?

Additionally, I think it makes sense to simplify the usage and change direction signature to:

direction ({ abbr: boolean, type: DirectionType, types: DirectionType[]})

// @examples
faker.address.direction() // 'north'
faker.address.direction({ abbr: true }) // 'N'
faker.address.direction({ type: 'ordinal' }) // 'north west'
faker.address.direction({ abbr: true, type: 'ordinal' }) // 'NW'
faker.address.direction({ abbr: true, types: ['ordinal', 'secondaryIntercardinal']  }) // 'NNW'

And then deprecate the other methods? We might also skip secondaryIntercardinal...

@ST-DDT
Copy link
Member

ST-DDT commented Aug 3, 2022

@pkuczynski Please create a separate issue for that.

@pkuczynski
Copy link
Member

@pkuczynski Please create a separate issue for that.

Sure! #1228

@ST-DDT ST-DDT changed the title feat(locales.pl): add directions and directions abbr locale(pl): add directions and directions abbr Aug 5, 2022
@ST-DDT ST-DDT added p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug m: location Something is referring to the location module labels Aug 5, 2022
@Shinigami92 Shinigami92 changed the title locale(pl): add directions and directions abbr feat(locale): add directions and directions abbr to pl Aug 12, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Aug 16, 2022

@hankucz Could you please restore the original order? (N,E,S,W, NE, SE, SW, NW)
That way we can merge this and can easily automatically transform it once we change the implementation.

@hankucz
Copy link
Contributor Author

hankucz commented Aug 18, 2022

@ST-DDT original order restored

@Shinigami92 Shinigami92 enabled auto-merge (squash) August 19, 2022 07:22
@Shinigami92 Shinigami92 merged commit 7a718b9 into faker-js:main Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: locale Permutes locale definitions m: location Something is referring to the location module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants