[MGNLSTK-1325] Can't display calendar when locale is ja Created: 17/Dec/13  Updated: 29/Jan/14  Resolved: 21/Jan/14

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: templates
Affects Version/s: 2.7
Fix Version/s: 2.7.2

Type: Bug Priority: Neutral
Reporter: Masao Suda Assignee: Christopher Zimmermann
Resolution: Fixed Votes: 0
Labels: i18n, quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: JPEG File broken-calendar.jpg    
Template:
Acceptance criteria:
Empty
Date of First Response:
Epic Link: Add Japanese translation

 Description   

– Repro Steps. –
1. set the magnolia locale to ja (Japanese)
2. display calendar.
i.e.) display demo-project/news-and-events/events-overview.html

– Problem –
Calendar is not displayed correctry.

The following Exception occured.

ERROR ndering.engine.ModeDependentRenderExceptionHandler: Error while rendering [/demo-project/news-and-events/events-overview/extras/extras1/extrasItem0] with template [standard-templating-kit:components/extras/stkExtrasCalendar]: RenderException: java.lang.StringIndexOutOfBoundsException: String index out of range: 2
info.magnolia.rendering.engine.RenderException: java.lang.StringIndexOutOfBoundsException: String index out of range: 2

– Workaround –
1. edited /templating-kit/components/features/calendar
2. change

<th ${cmsfn.createHtmlAttribute('class', cssClass)}><abbr title="${date?string('EEEE')}">${date?string('EE')?substring(0,2)}</abbr></th>

to

<th ${cmsfn.createHtmlAttribute('class', cssClass)}><abbr title="${date?string('EEEE')}">${date?string('EE')}</abbr></th>

*omit substring method

– Reason –
When locale is ja, 'EE' format of Date outputs only one character. i.e. '月'



 Comments   
Comment by Christopher Zimmermann [ 21/Jan/14 ]

We want to trim calendar days to max 2 chars so that the template looks okay. But some languages like japanese have only 1 char per day.
For calendar days: Check for the length of the string before calling substring to avoid exception in languages where the day of the week is less then 2 characters.
I added a silly min method to Calendar model, but I think its nice in that it makes the template ftl easy to read.

Generated at Mon Feb 12 07:35:30 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.