Skip to content

Commit 7bd363b

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 48aa45c commit 7bd363b

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-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: 30 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,28 @@ public abstract class HTMLConvertor {
163165
*/
164166
public static final String OPEN_H4 = "<h4>"; //$NON-NLS-1$
165167

168+
private static final Set<String> RTL_LANGUAGES = Set.of( //
169+
"ae", /* Avestan */ //$NON-NLS-1$
170+
"ar", /* "العربية", Arabic */ //$NON-NLS-1$
171+
"arc", /* Aramaic */ //$NON-NLS-1$
172+
"bcc", /* "بلوچی مکرانی", Southern Balochi */ //$NON-NLS-1$
173+
"bqi", /* "بختياري", Bakthiari */ //$NON-NLS-1$
174+
"ckb", /* "Soranî / کوردی", Sorani */ //$NON-NLS-1$
175+
"dv", /* Dhivehi */ //$NON-NLS-1$
176+
"fa", /* "فارسی", Persian */ //$NON-NLS-1$
177+
"glk", /* "گیلکی", Gilaki */ //$NON-NLS-1$
178+
"he", /* "עברית", Hebrew */ //$NON-NLS-1$
179+
"ku", /* "Kurdî / كوردی", Kurdish */ //$NON-NLS-1$
180+
"mzn", /* "مازِرونی", Mazanderani */ //$NON-NLS-1$
181+
"nqo", /* N"Ko */ //$NON-NLS-1$
182+
"pnb", /* "پنجابی", Western Punjabi */ //$NON-NLS-1$
183+
"ps", /* "پښتو", Pashto, */ //$NON-NLS-1$
184+
"sd", /* "سنڌي", Sindhi */ //$NON-NLS-1$
185+
"ug", /* "Uyghurche / ئۇيغۇرچە", Uyghur */ //$NON-NLS-1$
186+
"ur", /* "اردو", Urdu */ //$NON-NLS-1$
187+
"yi" /* "ייִדיש", Yiddish */ //$NON-NLS-1$
188+
);
189+
166190
/**
167191
* Opens a new <code>&lt;td&gt;</code> with the given width attribute set
168192
*
@@ -173,4 +197,8 @@ public static String openTD(int width) {
173197
buffer.append("<td width=\"").append(width).append("%\">"); //$NON-NLS-1$//$NON-NLS-2$
174198
return buffer.toString();
175199
}
200+
201+
private static boolean isRightToLeft() {
202+
return RTL_LANGUAGES.contains(Locale.getDefault().getLanguage());
203+
}
176204
}

0 commit comments

Comments
 (0)