telegram-react
telegram-react copied to clipboard
Problem in showing RTL texts
It would be a great idea to show RTL texts RTL. This simple function would help to check if a text is RTL or not,
const isRtl = (text) => {
var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF' + '\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
rtlDirCheck = new RegExp('^[^' + ltrChars + ']*[' + rtlChars + ']');
return rtlDirCheck.test(text);
}
It's easy to use this and check if the content of a text element is RTL, and in that case add a class or style direction: rtl;
. It's doesn't take much effort but would be a great help to many people who use Persian/Arabic/Hebrew languages.