202 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
Latest 7 Posts
Document Conversion API now open source
Mon, Dec 4th 2017 31
HR Assistant – Document Conversion but different
Fri, Dec 1st 2017 15
Quick tip: access the application log files on Bluemix
Wed, Nov 15th 2017 5
HR Assistant – Hello Domino….
Mon, Nov 13th 2017 5
Quick tip: Make a backup of your Cloudant database
Fri, Nov 3rd 2017 4
HR Assistant – now available in every language
Wed, Nov 1st 2017 8
HR Assistant – what happened since last year
Fri, Oct 27th 2017 5
Top 10
Document Conversion API now open source
Mon, Dec 4th 2017 31
HR Assistant – Document Conversion but different
Fri, Dec 1st 2017 15
My steps in the JSF 2.0 world
Fri, Oct 24th 2014 12
Quick XPages tip: Show validation status icon on bootstrap tabs
Thu, Jul 9th 2015 12
Quick XPages tip: add Fullcalendar plugin to your application
Thu, Aug 27th 2015 11
I am an IBM Champion, again
Thu, Dec 15th 2016 10
Power of Themes part 2, the XML syntax
Mon, Jun 1st 2015 9
Update on my Cloudant connector for XPages
Fri, Apr 15th 2016 9
XPages Quick tip: Move Java files for a better Source Control experiences
Fri, Sep 23rd 2016 9
Angular 4 bug in combination with latest Typescript
Sat, Jul 1st 2017 9

XPages tip: add a new language to your app
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
Frank van der Linden    

import export

In a previous post I blogged about how to make a XPages application multi language.

The next step is to add 1 new language in total and no need to modify all the property documents of this new language one by one.

Export the property file

As I have the master property file, with all the labels and messages, in my application I can export this property file as a downloadable file.

I have trigger the code below from a XPage in the browser and will be produce txt file.

public void exportDefaultPropertyFile(){
List lines = new ArrayList();
XspHttpServletResponse response = null;
PrintWriter pw = null;
StringBuilder sb = new StringBuilder();
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext extCon = facesContext.getExternalContext();
response = (XspHttpServletResponse) extCon.getResponse();
pw = response.getWriter();

//only HTTP POST is allowed
HttpServletRequest request = (HttpServletRequest) extCon.getRequest();
//set up output object
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition", "attachment; filename=default_properties.txt");
response.setDateHeader("Expires", -1);

int row = 0;
ResourceBundle bundle = JSFUtil.getXSPContext().bundle(DEFAULT_PROPERTIES_FILE);
if (bundle != null) {
Enumeration keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
String value = bundle.getString(key);
row += 1;

Collections.sort(lines, new Comparator() {
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);

//put together
for(String line : lines){


} catch (Exception e) {


try {
} catch (IOException e1) {
} finally{

Translate and save new properties file

Now I can translate all the labels at once and save the property file. To make it easier for the importer it expects a special formatted name of the newly created property file.

countrycode_countryname.txt, e.g. nl_nederlands.txt

Import the new language file

The importer code is triggered by a button on XPage with a file upload and first save the document as temporary document. It will pass on to the actual importer code in my FileController bean.

The importer will first split the attachment name in the right variables.

Next these variables will passed to my LanguageHandler to check if the language is already present. If it is not present it will create a language document and add it to list, which will populate the language dropdown in the navigation top bar.

After this action it is time to import the lines from the imported properties file. There will be a check if there is already a property available with this key and country code.

public void importPropertyFile(DominoDocument dominodocument) {
InputStream is = null;
BufferedReader br = null;
try {
Document document = XSPUtil.wrap(dominodocument.getDocument());
String attachmentName = document.getItemValueString("importfile");
attachmentName = attachmentName.substring(3, attachmentName.length()).trim();

String[] attachmentNameSplit = attachmentName.split("_");
String code = attachmentNameSplit[0].toUpperCase();
String language = StringUtils.capitalize(attachmentNameSplit[1].substring(0,attachmentNameSplit[1].indexOf(".") ));

handleLanguage(language, code);
EmbeddedObject embObj = (EmbeddedObject) document.getAttachment(attachmentName);
is = embObj.getInputStream();
br = new BufferedReader(new InputStreamReader(is));
String line = null;
int row = 0;
while ((line = br.readLine()) != null) {
String[] lineSplit = line.split("=");
String key = lineSplit[0];
String value = lineSplit[1];
if(!PropertyHandler.get().hasProperty(key, code)){
//is not present yet, so create and add property
//this way we can run in it multiple time without running in trouble

Document docProperty = XSPUtil.getCurrentDatabase().createDocument();
docProperty.replaceItemValue("form", "property");
docProperty.replaceItemValue("code", code);
docProperty.replaceItemValue("language", language);
docProperty.replaceItemValue("key", key);
docProperty.replaceItemValue("value", value);


//add to Properties list
PropertyHandler.get().addProperty(key, value, code);

row += 1;

JSFUtil.addMessage(FacesMessage.SEVERITY_INFO, LanguageHandler.get().getLanguageString("message.import.properties.total") + (row));

//remove the Document
} catch (Exception e) {
} finally{
if (br != null) {
try {
} catch (IOException e) {


Happy coding

twittergoogle_plusredditpinterestlinkedintumblrby feather

The post XPages tip: add a new language to your app appeared first on elstar IT.

Mar 08, 2016
9 hits

Recent Blog Posts
Document Conversion API now open source
Mon, Dec 4th 2017 8:25a   Frank van der Linden
Last Friday I wrote how we implemented Document Conversion in HR Assistant. Part of the solution was a new project, Document Conversion API We decided to open source it. Below I copied the details from the previous post about this new project. Details It is a Spring boot application, which can run stand alone. I have added also Docker support. See the ReadMe for more details Endpoints Url: /api/convert-to-plain-text Method: POST Consumes: File Produces: JSON { “convertedText”: &
HR Assistant – Document Conversion but different
Fri, Dec 1st 2017 10:46a   Frank van der Linden
Document conversion was one of the top items on our backlog which didn’t make it in the final contest version. What is Watson Document Conversion On the Document Conversion API documentation page is the following stated about this service “The IBM Watson™ Document conversion service converts a single HTML, PDF, or Microsoft Word™ document into a normalized HTML, plain text, or a set of JSON-formatted Answer units that can be used with other Watson services. Carefully inspect output
Quick tip: access the application log files on Bluemix
Wed, Nov 15th 2017 1:03p   Frank van der Linden
Last night when I deployed a new version of HR Assistant to Bluemix I ran in some troubles. When the application was deployed and tried to access it via de Application URL I got a 500 internal error. Find the log First step was to open the log page, but was not very explanatory. Next step was to open Kibana. There I found more information. As you can see, I need to consult the error-log-0.xml file for more information The challenge is where to find this log file. Solution I started, in my case
HR Assistant – Hello Domino….
Mon, Nov 13th 2017 7:03a   Frank van der Linden
While we developed HR Assistant it ran smoothly on a Domino server, but it was not using some strength of Domino, security. Run on Domino I made HR Assistant aware of the runtime it runs on, it ‘knows’ when it runs on Bluemix. If that is the case our own developed login features comes in place, but… When it runs on Domino it will enforce the ACL, which gave great advantages, by assign groups to the 3 roles of the application, HR, JobApplicant and Administrator. In the end you a
Quick tip: Make a backup of your Cloudant database
Fri, Nov 3rd 2017 3:04p   Frank van der Linden
For HR Assistant, we use Cloudant database as storage of the data on the IBM Cloud Today I was thinking about ‘what if we loose our data as something goes wrong’. It is not likeable, but still possible. Make a backup On IBM Cloud, there is documentation about making a backup of your data. So installed the npm package couchbackup  and run the command as described in the documentation.] I changed only to store the output as a JSON file. When I run the command I hit an error about au
HR Assistant – now available in every language
Wed, Nov 1st 2017 6:58p   Frank van der Linden
One of the latest features I had add to HR Assistant is multi language support. It was obvious we needed this new features, as not the whole world is talking English One of my goals was to make it as configurable as possible. Default language The default language of the application is still English. All the labels are stored in the application it self as a property file if there are no languages configured these property file will be loaded. On the overview page of the languages is the possibil
HR Assistant – what happened since last year
Fri, Oct 27th 2017 11:12a   Frank van der Linden
Last year I won together with Frédéric Dehédin the ICS Developer Contest 2016 with our HR Assistant application, a cognitive solution to help the HR department with of IBM Watson services. As required the code was open sourced at a public Github repository. What happened with HR Assistant since that moment? From public to closed First thing was to take the code back In the final stage of the development we were not able to include all the features we wanted upfront. So we skipped some featu
Domino Version 10 and Beyond – a few toughts
Thu, Oct 26th 2017 6:52a   Frank van der Linden
Yesterday Inhi Cho Suh announced the strategic partnership between IBM and HCL to move the Notes and Domino Family forward. In 2018 a brand new version, 10, will be released. For lots of customers who have invested in Domino applications it is very good news. Less need to move away to other products. IBM will be organising jams, to define the future of the product. It is a great opportunity to show interest in the product and what you think is most important in the product. Sign up know to kee
IBM Champion nominations 2018 are open
Mon, Oct 23rd 2017 2:27p   Frank van der Linden
It is the time of the year again. Time to thanks your favourite IBM technology expert by nominate them as IBM Champion 2018. More details on this blog post by the Libby Ingrassia, the overall IBM Champion manager, or watch the video below. The deadline to nominate is November 13th, so start nominating today, https://www.ibm.com/developerworks/champion/?ca=dw-_-IBMChampion-_-dwtv-Featured-_-category by The post IBM Champion nominations 2018 are open appeared first on elstar IT.
Spring boot and Thymeleaf – rapid application development
Fri, Oct 20th 2017 6:02p   Frank van der Linden
At one of my customers I was able to use to build an application with preview functionality of a business critical application. As usual the business wants this application as soon as possible. So the obvious choice was Spring boot in combination with Thymeleaf. Spring Boot Spring boot created spring based applications which can run as a runnable jar, with embedded a Tomcat server. But a Spring boot application can with a few tweaks run on a Websphere Application Server or Websphere Liberty Pro

Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition