-
Notifications
You must be signed in to change notification settings - Fork 6
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
Normalize locale input format before matching, fix #3 #4
base: master
Are you sure you want to change the base?
Normalize locale input format before matching, fix #3 #4
Conversation
- Repace `-` with `_` - Capitalize characters after `_`
@@ -60,6 +60,14 @@ const localesToNonStandardFacebookLocales = _(facebookVirtualLocales) | |||
.value() | |||
|
|||
export const bestFacebookLocaleFor = locale => { | |||
// Normalize locale input format | |||
if (locale.includes('-')) { |
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.
The if (locale.includes('-')) {
check is moot for this as replace
is a noop if there's no -
in the string.
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.
I treat this just about kind of style, I know the results is totally the same :)
locale = locale.replace('-', '_'); | ||
} | ||
if (locale.includes('_')) { | ||
locale = locale.split('_')[0] + '_' + locale.split('_')[1].toUpperCase(); |
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.
This can be written more readable:
const [language, territory] = locale.split('_');
locale = `${language}_${territory.toUpperCase()}`;
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.
I'm not sure which style is more acceptable, would like to wait for review from its maintainer.
@dleshem do you mind to help review this PR? Thanks! |
@PeterDaveHello Sorry, I no longer work in Wix... |
Sorry, didn't notice that 😅 |
-
with_
_
Original results looks odd in some situations:
The corrected results would be as fellow: