<legend id='3Nqg5'><style id='3Nqg5'><dir id='3Nqg5'><q id='3Nqg5'></q></dir></style></legend>
    1. <i id='3Nqg5'><tr id='3Nqg5'><dt id='3Nqg5'><q id='3Nqg5'><span id='3Nqg5'><b id='3Nqg5'><form id='3Nqg5'><ins id='3Nqg5'></ins><ul id='3Nqg5'></ul><sub id='3Nqg5'></sub></form><legend id='3Nqg5'></legend><bdo id='3Nqg5'><pre id='3Nqg5'><center id='3Nqg5'></center></pre></bdo></b><th id='3Nqg5'></th></span></q></dt></tr></i><div id='3Nqg5'><tfoot id='3Nqg5'></tfoot><dl id='3Nqg5'><fieldset id='3Nqg5'></fieldset></dl></div>

      <tfoot id='3Nqg5'></tfoot>

        <small id='3Nqg5'></small><noframes id='3Nqg5'>

          <bdo id='3Nqg5'></bdo><ul id='3Nqg5'></ul>
      1. 如何在java中找出依赖于语言环境的文本方向?

        How to find out locale-dependent text orientation in java?(如何在java中找出依赖于语言环境的文本方向?)

          <small id='2bW3k'></small><noframes id='2bW3k'>

          <tfoot id='2bW3k'></tfoot>

        1. <i id='2bW3k'><tr id='2bW3k'><dt id='2bW3k'><q id='2bW3k'><span id='2bW3k'><b id='2bW3k'><form id='2bW3k'><ins id='2bW3k'></ins><ul id='2bW3k'></ul><sub id='2bW3k'></sub></form><legend id='2bW3k'></legend><bdo id='2bW3k'><pre id='2bW3k'><center id='2bW3k'></center></pre></bdo></b><th id='2bW3k'></th></span></q></dt></tr></i><div id='2bW3k'><tfoot id='2bW3k'></tfoot><dl id='2bW3k'><fieldset id='2bW3k'></fieldset></dl></div>
          1. <legend id='2bW3k'><style id='2bW3k'><dir id='2bW3k'><q id='2bW3k'></q></dir></style></legend>

              <bdo id='2bW3k'></bdo><ul id='2bW3k'></ul>

                    <tbody id='2bW3k'></tbody>

                  本文介绍了如何在java中找出依赖于语言环境的文本方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在编写格式和解析引擎时,我想知道 - 给定 j.u.Locale,如果一般文本方向是从右到左(字母字符).我看到的是:

                  While I am writing a format and parse engine, I would like to find out - given a j.u.Locale, if the general text orientation is right-to-left (letter chars). What I have seen is:

                  1.) Character#getDirectionality(char) 这需要了解要解析的具体字符,由于可能存在填充字符,这并不总是容易的.

                  1.) Character#getDirectionality(char) This requires the knowledge of the concrete char to be parsed which is not always easy due to possible fill chars.

                  2.) java.awt.ComponentOrientation#getOrientation(Locale) 这个方法对我来说有两个问题.首先,我不想依赖 awt 或其他 gui 库(预计 Java 以后可能会模块化).第二个也是更重要的:这个方法在 OpenJDK 和 Android 中的实现只是使用了一种非常简单的方法,即:如果语言是 (ar, fa, iw, ur) 之一,那么方法就是 RIGHT_TO_LEFT.但是看看 Wikipedia-ISO-639 似乎有更多的语言有权利-to-left-orientation,例如 ISO-639 代码he"(希伯来语).

                  2.) java.awt.ComponentOrientation#getOrientation(Locale) This method has two problems for me. First I would not like to be dependent on awt or other gui libraries (anticipating a possible later modularization of Java). Second and more important: The implementation of this method in OpenJDK and Android just use a very simple approach, namely: If the language is one of (ar, fa, iw, ur) then the method says RIGHT_TO_LEFT. But looking at Wikipedia-ISO-639 it appears that there are more languages which have a right-to-left-orientation, for example the ISO-639-code 'he' (hebrew).

                  所以我现在的问题是,你知道更好的方法吗?目前我倾向于只使用 Wikipedia 列表,即使用更好的语言列表来改进 java.awt.ComponentOrientation 方法.

                  So my question now is, do you know a better approach? At the moment I tend just to use the Wikipedia list, that is, to refine the java.awt.ComponentOrientation approach with a better language list.

                  推荐答案

                  经过进一步研究,我发现语言代码'iw'只是'he'的旧形式.而表达式 new Locale("he").getLanguage() 将提供结果iw"!

                  After some further research I have found out that the language code 'iw' is just the old form for 'he'. And the expression new Locale("he").getLanguage() would provide the result "iw"!

                  尽管如此,ComponentOrientation 方法显然不是最新的,因为根据 Wikipedia,它缺少以下语言:

                  Nevertheless the ComponentOrientation-method is obviously not up to date, since it is missing the following languages according to Wikipedia:

                  yi(意第绪语加旧形式 ji)、dv(马尔代夫语)、ps(普什图语)和 ha(豪萨语)

                  yi (yiddish plus old form ji), dv (maldivian), ps (pashto) and ha (hausa)

                  所以我改进了 ComponentOrientation 的方法并添加了这些缺失的语言.最终代码如下所示:

                  So I have refined the approach of ComponentOrientation and added these missing languages. The final code looks like this:

                  private static final Set<String> RTL;
                  
                  static {
                    Set<String> lang = new HashSet<String>();
                    lang.add("ar");
                    lang.add("dv");
                    lang.add("fa");
                    lang.add("ha");
                    lang.add("he");
                    lang.add("iw");
                    lang.add("ji");
                    lang.add("ps");
                    lang.add("sd");
                    lang.add("ug");
                    lang.add("ur");
                    lang.add("yi");
                    RTL = Collections.unmodifiableSet(lang);
                  }
                  
                  public static boolean isTextRTL(Locale locale) {
                    return RTL.contains(locale.getLanguage());
                  }
                  

                  这篇关于如何在java中找出依赖于语言环境的文本方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <small id='xH7nN'></small><noframes id='xH7nN'>

                  • <bdo id='xH7nN'></bdo><ul id='xH7nN'></ul>
                    <i id='xH7nN'><tr id='xH7nN'><dt id='xH7nN'><q id='xH7nN'><span id='xH7nN'><b id='xH7nN'><form id='xH7nN'><ins id='xH7nN'></ins><ul id='xH7nN'></ul><sub id='xH7nN'></sub></form><legend id='xH7nN'></legend><bdo id='xH7nN'><pre id='xH7nN'><center id='xH7nN'></center></pre></bdo></b><th id='xH7nN'></th></span></q></dt></tr></i><div id='xH7nN'><tfoot id='xH7nN'></tfoot><dl id='xH7nN'><fieldset id='xH7nN'></fieldset></dl></div>

                    1. <tfoot id='xH7nN'></tfoot>

                        <tbody id='xH7nN'></tbody>

                    2. <legend id='xH7nN'><style id='xH7nN'><dir id='xH7nN'><q id='xH7nN'></q></dir></style></legend>