-
Notifications
You must be signed in to change notification settings - Fork 3
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
Accept language on 2 or 5 chars #3
Conversation
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.
You could replace mb_strlen
calls with this regex:
preg_match('/^((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<region>[A-Za-z]{2}|[0-9]{3}))?)$/', $language);
It is incomplete but should work for almost all cases.
References:
@Kdecherf I'm not sure about the regex, |
@j0k3r hm the results I see on your snippet are expected |
Hmm does the comparison in my last commit is ok then? |
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 regex in last commit looks good, I let you squash before merging
Accept `en`, `fr`, etc.. but also `de-DE`, `en-US`, etc. Also replace dead image in _tests_ by a real image. And use Regex to validate the language
Accept
en
,fr
, etc.. but alsode-DE
,en-US
, etc.Also replace dead image in tests by a real image.
And use Regex to validate the language
Related: