WebHelp customization: Localized text in HTML fragment

Frank Ralf
Posts: 391
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

WebHelp customization: Localized text in HTML fragment

Post by Frank Ralf » Mon Jun 03, 2019 6:02 pm

Hi,

I'm customizing the WebHelp Responsive and want to insert an HTML fragment that contains text that must be localized.

I've read "How to Localize the Interface of WebHelp Responsive Output" and suppose that I must add my string to one of the translation files and then reference it in the HTML fragment, probably using the i18n macro: ${i18n(string.id)}.

Is that correct?

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

tonra
Posts: 7
Joined: Wed Jun 05, 2019 10:39 am
Location: Germany

Re: WebHelp customization: Localized text in HTML fragment

Post by tonra » Wed Jun 05, 2019 11:47 am

Hello Frank,

I was just going to post a quite similar question when I found your thread.

In my understanding, the localization features provided by Oxygen are limited to the interface of the output (e. g. search field placeholder text etc.).

I use HTML fragments containing localized content, too. It's wrapped in several div elements with the lang attribute.
In a first approach, I used JavaScript to display elements with the relevant language only. However, I would prefer using an XSLT-based solution instead. Unfortunately, I'm currently failing at accessing the HTML fragment file from the XSLT stylesheet (createMainPage.xsl) in order to copy the relevant (localized) content to the target (Main Page, wt_index.html). I've already checked commonComponentsExpander.xsl which seems to be responsible for filling the HTML fragments but haven't found a solution yet.

Best regards,
Anton

ionela
Posts: 281
Joined: Mon Dec 05, 2011 6:08 pm

Re: WebHelp customization: Localized text in HTML fragment

Post by ionela » Fri Jun 07, 2019 3:31 pm

Hi Frank,

Your finding are corrects. This is recommended way to localize that string.

Regards,
Ionela
Ionela Istodor
oXygen XML Editor and Author Support

Frank Ralf
Posts: 391
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp customization: Localized text in HTML fragment

Post by Frank Ralf » Tue Jun 11, 2019 3:53 pm

Hi Ionela,

Many thanks for this information.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

Frank Ralf
Posts: 391
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp customization: Localized text in HTML fragment

Post by Frank Ralf » Tue Jun 11, 2019 4:37 pm

Here's an example for the syntax, taken from com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/wt_search.html:

Code: Select all

<whc:macro value="${i18n(jump.to.results)}" />
The string is defined in com.oxygenxml.webhelp.responsive\oxygen-webhelp\resources\localization\strings-en-us.xml:

Code: Select all

<str name="jump.to.results" js="true" php="false">Jump to search results</str>
Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

tonra
Posts: 7
Joined: Wed Jun 05, 2019 10:39 am
Location: Germany

Re: WebHelp customization: Localized text in HTML fragment

Post by tonra » Tue Aug 13, 2019 1:55 pm

Hi,

thank you for posting an example, Frank. This approach meets my requirements almost perfectly.
There is only one thing I am currently missing: Is there an (elegant) way to add line breaks to a string?
I have tried several ways without success.

Best regards,
Anton

Frank Ralf
Posts: 391
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp customization: Localized text in HTML fragment

Post by Frank Ralf » Wed Aug 14, 2019 12:44 pm

Hi Anton,

The usual way in XML is to use one or both of the following entities:

Carriage return: &#xD;
Line feed: &#xA;

I haven't tested this, though.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

Post Reply