in my java gxt-project, I have a template, in which I have the following tpl tags, which decide, depending on a parenttitle, if the title has to be italics.
<tpl if="titleORG != """>
<tpl if="ParentTitleORG == """><i></tpl>
<b>{titleORG}<tpl if="subtitleORG != """>: {subtitleORG}</tpl></b>
<tpl if="ParentTitleORG == """></i></tpl>
</tpl>
<tpl if="titleEN != """>
<tpl if="officialTitleTranslation"> / {titleEN}<tpl if="subtitleEN != """>: {subtitleEN}</tpl></tpl>
</tpl>.
Lately, I got a ticket, whether it is possible to make title italics only, if they are not chinese or korean.
Any idea, how I can check for that?
Thanks,
Eric
You will have to check it in the Class you pass into the XTemplate.
Add a boolean (I'll call it ckj) and set it in your constructor. [Using the Person example from GXT documentation]
public class Person {
private String name;
private boolean ckj;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
this.ckj=containsJapanese(name);
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public boolean containsCKJ(String s) {
return s.codePoints()
.anyMatch(codepoint -> (Character.UnicodeScript.of(codepoint) == Character.UnicodeScript.HAN
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_COMPATIBILITY
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_STROKES
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.ENCLOSED_IDEOGRAPHIC_SUPPLEMENT
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.KANGXI_RADICALS
|| Character.UnicodeBlock.of(codepoint) == Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS
));
}
}
Then you can use an if expression in your template.
<tpl if="!ckj">
//italics
<tpl if="ckj">
//no italics
More discussion on checking for CKJ characters is here Differentiating CJK languages (Chinese, Japanese, Korean) in Android