1313 *******************************************************************************/
1414package org .eclipse .pde .api .tools .internal .search ;
1515
16- import com .ibm .icu .util .ULocale ;
16+ import java .util .Locale ;
17+ import java .util .Set ;
1718
1819/**
1920 * Contains strings and methods for writing HTML markup
@@ -77,7 +78,8 @@ public abstract class HTMLConvertor {
7778 /**
7879 * Opening html tag: <code><html></code>
7980 */
80- public static final String OPEN_HTML = !ULocale .getDefault ().isRightToLeft () ? "<html>\n " : "<html dir=\" rtl\" >\n " ;//$NON-NLS-1$ //$NON-NLS-2$
81+ public static final String OPEN_HTML = !isRightToLeft () ? "<html>\n " //$NON-NLS-1$
82+ : "<html dir=\" rtl\" >\n " ;//$NON-NLS-1$
8183 /**
8284 * Closing html tag: <code><html></code>
8385 */
@@ -163,6 +165,30 @@ public abstract class HTMLConvertor {
163165 */
164166 public static final String OPEN_H4 = "<h4>" ; //$NON-NLS-1$
165167
168+ // List of RTL Languages taken from
169+ // https://raw.githubusercontent.com/shadiabuhilal/rtl-detect/2eed8a33276461a24e7033d1d3a115ee64aee3f5/lib/rtl-detect.js
170+ private static final Set <String > RTL_LANGUAGES = Set .of ( //
171+ "ae" , /* Avestan */ //$NON-NLS-1$
172+ "ar" , /* "العربية", Arabic */ //$NON-NLS-1$
173+ "arc" , /* Aramaic */ //$NON-NLS-1$
174+ "bcc" , /* "بلوچی مکرانی", Southern Balochi */ //$NON-NLS-1$
175+ "bqi" , /* "بختياري", Bakthiari */ //$NON-NLS-1$
176+ "ckb" , /* "Soranî / کوردی", Sorani */ //$NON-NLS-1$
177+ "dv" , /* Dhivehi */ //$NON-NLS-1$
178+ "fa" , /* "فارسی", Persian */ //$NON-NLS-1$
179+ "glk" , /* "گیلکی", Gilaki */ //$NON-NLS-1$
180+ "he" , /* "עברית", Hebrew */ //$NON-NLS-1$
181+ "ku" , /* "Kurdî / كوردی", Kurdish */ //$NON-NLS-1$
182+ "mzn" , /* "مازِرونی", Mazanderani */ //$NON-NLS-1$
183+ "nqo" , /* N"Ko */ //$NON-NLS-1$
184+ "pnb" , /* "پنجابی", Western Punjabi */ //$NON-NLS-1$
185+ "ps" , /* "پښتو", Pashto, */ //$NON-NLS-1$
186+ "sd" , /* "سنڌي", Sindhi */ //$NON-NLS-1$
187+ "ug" , /* "Uyghurche / ئۇيغۇرچە", Uyghur */ //$NON-NLS-1$
188+ "ur" , /* "اردو", Urdu */ //$NON-NLS-1$
189+ "yi" /* "ייִדיש", Yiddish */ //$NON-NLS-1$
190+ );
191+
166192 /**
167193 * Opens a new <code><td></code> with the given width attribute set
168194 *
@@ -173,4 +199,8 @@ public static String openTD(int width) {
173199 buffer .append ("<td width=\" " ).append (width ).append ("%\" >" ); //$NON-NLS-1$//$NON-NLS-2$
174200 return buffer .toString ();
175201 }
202+
203+ private static boolean isRightToLeft () {
204+ return RTL_LANGUAGES .contains (Locale .getDefault ().getLanguage ());
205+ }
176206}
0 commit comments