RTL在网页上用破折号反转数字 [英] RTL is on web page reverses numbers with a dash

查看:202
本文介绍了RTL在网页上用破折号反转数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的网站显示与数字混合的希伯来文字,并且有一个数字在中间有一个破折号,中间的破折号的数字显示RTL。例如,对于文本:
רמה4-0 ,应显示 4-0 而不是 0-4 ,因为它是数字序列,并且'4'在'0'之前。但是,在我检查的浏览器上,它显示'4'之前的'0'。

When my website displays Hebrew text mixed with numbers, and there is a number with a dash in the middle, the number with the dash in the middle is displayed RTL. For example, with the text: רמה 4–0, it should display 4-0 instead of 0-4, since it is a numeral sequence, and the '4' precedes the '0'. However, on the browsers I checked, it displays the '0' before the '4'.

由于这可能发生在系统数据的任何地方,更好的是拥有一个不需要类似的CSS解决方案:

Since this could occur any place in the system data is displayed, it would be much preferable to have a CSS solution that does not require something like:

<span style="direction:ltr">4-0</span>

文本的大致方向应保持为RTL,但应以LTR显示带有破折号的数字。应在主要浏览器(IE,Firefox,Chrome)上正常显示。

The general direction for text should remain RTL, but numbers with dashes should be displayed LTR. Should display properly on the major browsers (IE, Firefox, Chrome).

推荐答案

您可以嵌入从左到右 right-to-left 标记字符(& lrm; & rlm; )在数字序列之前和之后 - 这不需要任何额外的标记,没有分隔符,并且将保留源文档中的文本顺序。

You can embed the left-to-right and right-to-left marker characters (&lrm; and &rlm; respectively) before and after the numeric sequences - this does not need any extra markup, no delimiters and will preserve the text order in the source document.

另一种方法是, em>一些标记以用短划线分隔数字(类似于您所做的),因为Unicode BIDI算法在没有帮助(lrm和rlm)的情况下不能很好地处理这个特定场景。

An alternative is to have some markup to delimit the numbers with dashes (similar to what you have done), as the Unicode BIDI algorithm just doesn't handle this specific scenario very well without help (lrm and rlm).

CSS不需要像你做的那样内联,但是你仍然需要像下面这样:

There is no need for the CSS to be inline as you have done, but you will still need something like:

CSS :

.numdash
{
  direction: ltr;
}

HTML:

<span class="numdash">4-0</span>

第三个选项是颠倒数字,只需在标记中使用0-4,由bidi算法逆转。

A third option is that of reversing the numbers and simply using 0-4 in the markup and have that reversed by the bidi algorithm.

这篇关于RTL在网页上用破折号反转数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆