Mention feature is not working for urdu user names.
Hi,
mention feature is working nice for English user names but it is not working for Urdu user names, any one knows about this issue?
Best Answer
-
R_J Admin
You might want to look at those two pull requests:
https://github.com/vanillaforums/Garden/pull/1653/files
https://github.com/vanillaforums/Garden/pull/1654/filesThe mention function has some inconveniences. Although you can specify allowed usernames in config with
$Configuration['Garden']['User']['ValidationRegex'] = '\d\w_'
and this will be used in the function that validates usernames, it is not used for the mentioning function. Neither is the setting$Configuration['Garden']['User']['ValidationLength'] = array(3,20)
used.
In fact, there are two functions dealing with mentions and both use slightly different regex!'/(^|[\s,\.>])@(\w{1,50})\b/i'
https://github.com/vanillaforums/Garden/blob/2.1/library/core/class.format.php'/(?:^|[\s,\.>])@(\w{3,20})\b/i'
https://github.com/vanillaforums/Garden/blob/2.1/library/core/functions.general.php
My aim with the above pull requests was to align the config settings with the functions. The change will not help if your users are allowed to use spaces in usernames but you could add a regex to your config which should allow Urdu characters to be validated and also be handled correctly in mentions6
Answers
What version number of Vanilla are you running?
The current mention system uses a regex to find and replace the
@name
with a link to the associated profile. It looks for word characterd ,\w
, after@
signs.The
\w
character only matches latin characters as far as I know.You would have to update the regex to also match urdu characters.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
verion is 2-0-18-8
How i can update regex?
Mentions are formatted through the
Mentions($Mixed)
method in/library/core/class.format.php
.You can override the mentions in an upgrade safe way by creating a MentionsFormatter class that has a FormatMentions method and including it in your conf.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
can you give an example to make it easy....i have very little knowledge about php.
I can't think of an example.
I can think of 3 easy solutions:
I can also think of the solution I would employ:
Mentions($Mixed)
method in/library/core/class.format.php
.I am not trying to blow you off. I don't have any experience with Urdu characters.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
You might want to look at those two pull requests:
https://github.com/vanillaforums/Garden/pull/1653/files
https://github.com/vanillaforums/Garden/pull/1654/files
The mention function has some inconveniences. Although you can specify allowed usernames in config with
$Configuration['Garden']['User']['ValidationRegex'] = '\d\w_'
and this will be used in the function that validates usernames, it is not used for the mentioning function. Neither is the setting$Configuration['Garden']['User']['ValidationLength'] = array(3,20)
used.In fact, there are two functions dealing with mentions and both use slightly different regex!
'/(^|[\s,\.>])@(\w{1,50})\b/i'
https://github.com/vanillaforums/Garden/blob/2.1/library/core/class.format.php'/(?:^|[\s,\.>])@(\w{3,20})\b/i'
https://github.com/vanillaforums/Garden/blob/2.1/library/core/functions.general.phpMy aim with the above pull requests was to align the config settings with the functions. The change will not help if your users are allowed to use spaces in usernames but you could add a regex to your config which should allow Urdu characters to be validated and also be handled correctly in mentions