如何处理RTL语言上pre 4.2版本的Andr​​oid? [英] How to handle RTL languages on pre 4.2 versions of Android?

查看:147
本文介绍了如何处理RTL语言上pre 4.2版本的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TextView中总是有问题,RTL(右至左)语言。因为我只知道怎么读希伯来语(除英语外),我将谈论它的问题:

TextView always had issues with RTL (Right-To-Left) languages. Since I know only how to read Hebrew (in addition to English), I will talk about its issues:

  • 文本对齐方式(我不是在谈论重力)。作为一个RTL语言,希伯来文所说的话由右至左(相对于英语这是相反的)。

  • Text alignment (and I'm not talking about gravity) . As an RTL language, Hebrew puts words from right to left (compared to English which is the opposite).

有关证明它是多么的烦人,想象,而不是显示出世界,你好。你通常会得到.Hello世界。这可以很容易地固定,如果你在一个句子有它,但它是当有多个标点字符更难了。

For demonstrating how annoying it is, imagine that instead of showing "Hello world." you usually get ".Hello world" . This could be easily fixed if you had it in a single sentence, but it's harder when there are multiple punctuations characters.

元音位置。希伯来语不需要元音,以阅读的文本,但有时很难阅读,没有他们(尤其是圣经)。对于元音,希伯来文有所谓的NIKUD,这实际上是一样的字母里面点。在Android上的问题是,他们通常被放置在错误的位置。

Vowels positions. Hebrew doesn't require vowels in order to read text, but sometimes it's very hard to read without them (especially the bible). For vowels, Hebrew has what is called "NIKUD", which are actually like dots inside the letters. The problem in Android was that they were usually positioned in the wrong location .

有关证明它是多么的烦人,想象,而不是显示出世界,你好。你通常会得到.eHlol owrld。即使你尝试修复它(在当前的把元音总是一个字符),信中的位置是不正确的(想象中的你好中的E将会像上面的H,为例子)。

For demonstrating how annoying it is, imagine that instead of showing "Hello world." you usually get ".eHlol owrld" . Even if you try to fix it (put the vowels always one character after the current one), the position in the letter wasn't correct (imagine that the "e" in "Hello" would be like above the "H", for example) .

仅在4.2版本(读这里,原生RTL支持下),谷歌已经修复了所有的希伯来文相关的问题(或者至少看起来如此)。

Only on version 4.2 (read here, under "Native RTL support") , Google has fixed all of the Hebrew related issues (or at least it seems so).

的问题与希伯来文已经引起了各方的以色列载体和每个自定义ROM制造商有自己的解决方案如何解决不同的问题,这使得它几乎不可能来处理pre RTL文本4.2设备。

the problems with Hebrew has caused each Israeli carrier and each custom ROM maker have its own solution of how to fix the different issues, which makes it practically impossible to handle RTL text on pre 4.2 devices.

事情可能会变得更加令人沮丧的情况下,文本包括希伯来文和英文字母。

Things can get even more frustrating in case the text include both Hebrew and English letters.

我看过很多网站在谈论这些问题,我已经尝试了解决方案的多种变体,没有一个解决了这个问题上的所有设备:

I've read many websites talking about those problems, and I've tried many variants of the solutions, none has solved the problem on all devices:

  • 有人建议把字符'\ u200F'(或'\ u202D')结尾/开始/两者的文字。

  • Some suggest to put the character '\u200F' (or '\u202D') at the end/start/both of the text.

有人建议使用<一个href="http://developer.android.com/reference/android/text/Html.html#fromHtml%28java.lang.String%29">Html.fromHtml()方法,把一些特别的东西在那里。

Some suggest using Html.fromHtml() method and put something special there.

有些人甚至建议使用web视图,而不是(也许使用<一个href="http://developer.android.com/reference/android/webkit/WebSettings.html#setDefaultTextEncodingName%28java.lang.String%29">WebSettings.setDefaultTextEncodingName() )。

Some even suggest to use the WebView instead (and maybe use WebSettings.setDefaultTextEncodingName() ).

有没有针对此问题一个明确的解决办法吗?

Is there a definite solution for this problem?

我会假设的最好的事情是,由于Android 4.2解决了这个,而Android是开源的,我们应该有其TextView的导入,我们可以使用图书馆,但谷歌并没有提供这样一个库呢。

I would assume the best thing is that because Android 4.2 solves this, and Android is open source, we should have its TextView imported into a library that we can use, but Google hasn't provided such a library yet.

推荐答案

可悲的是,我不认为有一个很好的解决方案(好的意思是做这项工作,并随时可用)。对于我们的支持希伯来语自己的Andr​​oid应用程序,我们使用我们开发多年的自定义渲染机制。渲染机制做的一切:专有的字体;双向(比迪)分析;字形布局;断行分析;文本流;等一些尝试使用Android原生的文字处理能力的问题(尤其是pre-4.2)是:

Sadly, I don't think there's a good solution ("good" meaning "does the job and is readily available"). For our own Android apps that support Hebrew, we use a custom rendering mechanism that we developed over many years. The rendering mechanism does everything: proprietary fonts; bidirectional (bidi) analysis; glyph placement; line break analysis; text flow; etc. Some of the problems trying to use native Android text handling capabilities (especially pre-4.2) are:

  1. 非常糟糕的字体。但是,你可以打包如的DejaVu 是pretty的良好的第三方字体。正确的字体可以创造奇迹与nekudot&mdash的定位;而te'amim 1 ,如果你需要的。 (我同意你的看法如何重要指向正确的位置是,阅读希伯来文与错位的nekudot就像读一满屏的 CAPTCHA系统

  1. Really crappy fonts. However, you can package third-party fonts like DejaVu that are pretty good. The right font can do wonders with positioning of nekudot—and te'amim1, if you need that. (I agree with you about how important correct pointing placement is; reading Hebrew text with misplaced nekudot is like reading a screen-full of CAPTCHAs.)

越野车比迪烟的分析。是什么使得它更糟糕的是,错误似乎是不同的Andr​​oid版本不同。修改文本,包括战略地位比迪烟的格式codeS(RTL标志; LTR标记;等等)可以克服许多这样的错误(见讨论的此处,这是不特定于Android的)。然而,这是一个讨厌这样做,因为当中的Andr​​oid版本不一致,这和,这是很难predict提前帮什么框架将需要。

Buggy bidi analysis. What makes it worse is that the bugs seem to be different for different versions of Android. Modifying the text to include strategically placed bidi formatting codes (RTL mark; LTR mark; etc.) can overcome many of these bugs (see the discussion here, which isn't specific to Android). However, it's a nuisance to do this and, because of the inconsistencies among Android versions, it is difficult to predict in advance what help the framework is going to need.

没有(或未经深思熟虑)的从右到左的问题框架级意识。例如,好运气得到滚动条显示在希伯来TextView的左侧。对于我们的应用程序,我们必须建立一个完整的滚动条系统只是为了得到这个工作,我们怎么想。 (良认为Android是开源的!)

No (or poorly thought out) framework-level awareness of right-to-left issues. For instance, good luck getting the scroll bar to display on the left side of a Hebrew TextView. For our apps, we had to build an entire scroll-bar system just to get this to work how we wanted. (Good think Android is open source!)

普线和字断分析。至少有一个早期版本的Andr​​oid上,我们测试的认为每个nikud标记是一个字边界。当涉及到换行符,系统往往不知道如何处理希伯来语标点符号一样maqaf,gershayim,或SOF帕苏克。

Poor line and word break analysis. At least one early version of Android on which we tested thought that each nikud mark was a word boundary. When it comes to line breaks, the system often doesn't know how to handle Hebrew punctuation like maqaf, gershayim, or sof pasuk.

一些较新的Uni code字符(比如HOLAM HASER FOR VAV&mdash; U + 05BA&mdash;新统一code 5.0)。无法识别由系统希伯来语脚本

Some of the newer Unicode characters (like HOLAM HASER FOR VAV—U+05BA—new to Unicode 5.0) are not recognized as Hebrew script by the system.

我的建议是,除非你是ppared建立$ P $自顶至底的文字处理系统你自己,你放弃了高品质的文字显示,pre-4.2版本的Andr​​oid,尤其是当您需要支持nekudot和te'amim。此外,计划使用我在第二点以上提到的技术。

My recommendation is that, unless you are prepared to build a top-to-bottom text handling system yourself, you give up on high-quality text display on pre-4.2 versions of Android, particularly if you need to support nekudot and te'amim. Also, plan to use the techniques I mentioned in the first two points above.

1 圣经的cantillation标记

1 biblical cantillation marks

这篇关于如何处理RTL语言上pre 4.2版本的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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