2

I have about 30 languages that my application needs to support. I have some fairly simple text that was provided for each of them, but within that text I do need to make one choice using {0, choice, 0# ...|0<...}

At present I have not even got as far as testing if this works because I am having a lot of trouble trying to convice my text editor to allow me to combine left to right and right to left text, but what I really want to know if this is even possible...

Question: Is it possible to use the Java message properties embedded choice with languages flowing from right to left.

If anyone can think of any additional tags to use for this question, I would be grateful.

sil
  • 433
  • 8
  • 20
  • 1
    I am not 100% sure if you mean to have something like [this](https://stackoverflow.com/questions/4648513/java-how-to-write-arabic-in-properties-file). Probably this might lead you to the solution. – Procrastinator May 13 '19 at 07:31
  • Can you a) show an example an b) tell us what your editor is. It sounds like your editor has a hard time to use LTR characters like `{`, `}` and `choice` interspersing RTL text? Might be time to look for a better editor. – Erwin Bolwidt May 13 '19 at 08:01

1 Answers1

1

The short answer is yes it is possible. It is a thorny issue, but BIDI (bi-directionl) support is an issue of the text editor not yours. So if your text editor supports it (and most editors do) then it is possible. First you have to make sure that you use an encoding (character set) that supports multiple languages - UTF-8 is recommended (but also UTF-16 and may be some others may work) as opposed to ISO-8859-X (where X is a single digit) that supports just 2 languages. Also you can write your Strings in property file or anywhere in the code as a unicode sequence.

There is an Open Source java library MgntUtils that has a Utility that converts Strings in any language (including special characters and emojis to unicode sequence and vise versa:

result = "Hello World";
result = StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence(result);
System.out.println(result);
result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString(result);
System.out.println(result);

The output of this code is:

\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064
Hello World

The library can be found at Maven Central or at Github It comes as maven artifact and with sources and javadoc

Here is javadoc for the class StringUnicodeEncoderDecoder

Michael Gantman
  • 7,315
  • 2
  • 19
  • 36
  • Thanks for the answer, but I am using native2ascii as recommended in an answer submitted to one of the questions linked in the comments. Do you think (as far as you know) that there is a significant difference between the two? I do like that native2ascii keeps ascii characters as ascii, making those characters readable to me (a westerner). – sil May 13 '19 at 08:59
  • 1
    The tools do the same work, but the library that I recommend can be integrated into your java code so you can convert back and force text within your code. Also MgntUtils lib allows you to keep both versions of the string. I don't know if native2ascii can be integrated in the code or only be used as an external tool. I would suggest to try MgntUtils and then choose what is fitting your needs better – Michael Gantman May 13 '19 at 10:09
  • 1
    Just looked a bit more into native2ascii. This is command line tool to convert to files. MgntUtils StringUnicodeEncoderDecoder class provides the same functionality to be used in your code. Based on that class it would be easy to write comand line tool as well but since native2ascii already exists I suppose there is no need. So I guess those tools are the same but native2ascii is comand line tool and MgntUtis is programatic equivalent to provide the same functionality in your code – Michael Gantman May 13 '19 at 10:16