Skip to content

Commit a98162d

Browse files
committed
Remove dependency to icu4j for html exports
The only reason for icu4j currently is to determine if a RTL language is used as the default locale on html exports. This replaces the fat (12MB!) dependency by a simpler variant that seems suitable for the sake of generating html reports.
1 parent 8573178 commit a98162d

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Export-Package: org.eclipse.pde.api.tools.internal;x-friends:="org.eclipse.pde.a
3333
org.eclipse.pde.api.tools.internal.search;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
3434
org.eclipse.pde.api.tools.internal.util;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui,org.eclipse.pde.api.tools.generator"
3535
Bundle-RequiredExecutionEnvironment: JavaSE-17
36-
Import-Package: com.ibm.icu.util,
37-
org.objectweb.asm;version="[9.5.0,10.0.0)",
36+
Import-Package: org.objectweb.asm;version="[9.5.0,10.0.0)",
3837
org.objectweb.asm.signature;version="[9.5.0,10.0.0)",
3938
org.objectweb.asm.tree;version="[9.5.0,10.0.0)"
4039
Bundle-Activator: org.eclipse.pde.api.tools.internal.provisional.ApiPlugin

apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/HTMLConvertor.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
*******************************************************************************/
1414
package 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>&lt;html&gt;</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>&lt;html&gt;</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>&lt;td&gt;</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

Comments
 (0)