YUI 对 RTL 语言的支持

发布于 2024-07-16 07:22:34 字数 105 浏览 15 评论 0原文

YUI 支持 rtl 语言吗? (rtl:从右到左,例如希伯来语或阿拉伯语)。

如果是这样,怎么办? 我想显示一个菜单栏,其中不同的菜单项从右边距附近开始并向左移动。

Does YUI support rtl languages? (rtl: right to left, such as hebrew or arabic).

If so, how?
I want to display a MenuBar where the different menu items start near the right margin and go to the left.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二货你真萌 2024-07-23 07:22:34

YUI 2.x 中不支持 RTL 语言。 我一年多前提交了一个关于它的错误,并得到回复说他们可能会在以后的版本中添加它。 (抱歉,自从他们切换到新的跟踪器后,我再也找不到这个错误了。)希望他们添加了对 YUI 3.x 的 RTL 支持,但我还没有查看预览版本(我也找不到他们提到添加RTL 支持)。

这并不是说 YUI 菜单不能实现 RTL,尽管由于没有内置支持,这需要一些工作。 我并不声称这在所有浏览器中 100% 有效,尤其是 IE。

首先,您需要菜单项向相反方向流动,并从页面的另一侧开始。 我相信这适用于大多数浏览器(当然,IE6 除外,呃 - 对于该浏览器,您需要做一些额外的工作,我不记得答案了):

.yuimenubaritem { float: right; }

其次,您需要 MenuBar 的子菜单来流动相反的方向。 您可以通过更改菜单配置的 submenualignment 属性来做到这一点:

// For the main submenu
new YAHOO.widget.MenuBar("id", { submenualignment: ["tr","br"] });

// You have to manually add all the Menus,
// so that you can set the submenualignment on each.
new YAHOO.widget.Menu("id", { submenualignment: ["tl","tr"] });

最糟糕的部分是尝试让键盘事件正常工作,因为此时按向右会使光标向左移动,反之亦然 -反之亦然。 为此,您必须劫持 MenuBar 的 _onKeyDown() 并更改它,这样,如果 MenuBar 设置为 RTL(将此信息存储在某个 var 中),它对左/右的处理会略有不同。 (抱歉,您必须自己解决这个问题,但这应该是一个简单的按键切换案例的问题)。

There is no support for RTL languages in YUI 2.x. I filed a bug about it over a year ago and got a response saying they might add it in a later release. (I can no longer find the bug since they switched to their new tracker, sorry.) Hopefully they're adding RTL support for YUI 3.x, but I haven't checked out the preview releases (nor can I find them mentioning adding RTL support).

That's not to say YUI menus cannot do RTL, though it takes a bit of work as there's no built-in support. I make no claims that this works 100% in all browsers, especially not IE.

First, you need the menu items to flow the opposite direction, and start on the opposite side of the page. I believe this works in most browsers (except IE6, of course, argh - for that browser, you need to do some extra work which I don't remember the answer to):

.yuimenubaritem { float: right; }

Second, you need the submenus of the MenuBar to flow the opposite direction. You can do this by changing the submenualignment attribute of your Menus' configurations:

// For the main submenu
new YAHOO.widget.MenuBar("id", { submenualignment: ["tr","br"] });

// You have to manually add all the Menus,
// so that you can set the submenualignment on each.
new YAHOO.widget.Menu("id", { submenualignment: ["tl","tr"] });

The worst part is trying to get the keyboard events to work correctly, as at this point pressing right makes the cursor go left and vice-versa. To do that, you'll have to hijack MenuBar's _onKeyDown() and change it so that, if the MenuBar is set RTL (store this info in a var somewhere), it processes left/right a bit differently. (Sorry, you'll have to figure this one out on your own, but it should be a simple matter of switching cases on key presses).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文