Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » how to control the language of date format (like month)
how to control the language of date format (like month) [message #688201] Fri, 24 June 2011 07:02 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
for a chart x-axis, it is datetime.
I set the format to short, date time.
when I run the report, it show as a expected, but when run in client machine, the date shown strange symbol, it seems it cannot shown the chinese character about month.
is there any method to force the output to english like
May/12/2011 1:00 pm
instead of chinese
5月/12/2011 晚上1:00

also, which setting control the display of date to chinese or english? in browser or in windows regional settings??
for e.g. MMM/dd/yy HH:mm, what setting control the display of MMM to english or chinese?

My birt designer version is 2.2.1

[Updated on: Fri, 24 June 2011 07:07]

Report message to a moderator

Re: how to control the language of date format (like month) [message #688366 is a reply to message #688201] Fri, 24 June 2011 14:24 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Have you seen these bugs?
https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;short_desc=chart%20chinese;short_desc_type=allwordssubstr;product=BIRT;classification=BIRT
You may also want to try and set in in beforeGeneration like:

function beforeGeneration(chart, icsc)
{

importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
importPackage( Packages.org.eclipse.birt.chart.model.attribute );

//currently the chart model only supports one base axis
xAxis = chart.getBaseAxes()[0];
yAxis = chart.getOrthogonalAxes( xAxis, true)[0];
yAxisNumber2 = chart.getOrthogonalAxes( xAxis, true)[1];
if ( xAxis.getType() == AxisType.DATE_TIME_LITERAL)
{
xAxis.setFormatSpecifier( JavaDateFormatSpecifierImpl.create("MM-dd-yyyy") );
}
}

Jason
Re: how to control the language of date format (like month) [message #688430 is a reply to message #688366] Fri, 24 June 2011 17:10 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
sorry, I click the link and see many bug about display chinese character is fixed or closed, but it did not mention which version contain the fixes, and my birt designer is 2.2.1, is it already contain the fix or not?

Also, from your provided code
xAxis.setFormatSpecifier( JavaDateFormatSpecifierImpl.create("MM-dd-yyyy") 


the format is "MM", which will display numeric month, but not the abbreviation of month (like Jan, Feb...).

Thanks in advance
Re: how to control the language of date format (like month) [message #688486 is a reply to message #688430] Fri, 24 June 2011 19:21 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Try using this function instead:

function beforeDrawAxisLabel( axis, label, context )
{
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.java.text);
//LINEAR_LITERAL
//LOGARITHMIC_LITERAL
//TEXT_LITERAL
//DATE_TIME_LITERAL
if (axis.getType() == AxisType.DATE_TIME_LITERAL)
{
value = label.getCaption().getValue();

importPackage( Packages.java.util );
var lc = new Locale("en", "US");
var dtf2 = new SimpleDateFormat("MMM/dd/yy", lc);
//var dtf2 = new SimpleDateFormat("MM/dd", context.getExternalContext().getScriptable().getLocale());
var dt = new Date(value);
var fn1 = dtf2.format(dt);
label.getCaption().setValue(fn1);
}
}

Format it in the chart like MM/dd/yy and then let the script change it.

BTW The reason I posted the list of bugs is because several of them had directions on correcting a font path issue on your system so the error does not show up.

Jason
Re: how to control the language of date format (like month) [message #689167 is a reply to message #688486] Mon, 27 June 2011 03:23 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
thanks for the reply, but I still want to know where to control the display format of date (chinese, english)? is it in client pc control panel?
But I find that some report show date in chinese and some show in english, I have attached my pc control panel regional setting and one of the report which show english date caption for reference.
for regional setting, my pc is set to show chinese date, but the report is show in english date caption...why would this happen?

Thanks in advance.
Re: how to control the language of date format (like month) [message #689419 is a reply to message #689167] Mon, 27 June 2011 15:59 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

By default the report engine should be using the local machine locale,
but it can be set in the web.xml of the viewer or as a url parameter to
the viewer &__locale=en_US. You can also set locale in script or using
the property editor for a given report element.

If you want a test of the date localization put a data element in the
report set its type to date and enter new Date(); as the expression. In
the designer you can hard code the viewer locale using :
window->preferences->Report Design->Preview->Choose your locale.

Jason

On 6/26/2011 11:23 PM, forums-noreply@eclipse.org wrote:
> thanks for the reply, but I still want to know where to control the display format of date (chinese, english)? is it in client pc control panel?
> But I find that some report show date in chinese and some show in english, I have attached my pc control panel regional setting and one of the report which show english date caption for reference.
> for regional setting, my pc is set to show chinese date, but the report is show in english date caption...why would this happen?
>
> Thanks in advance.
Re: how to control the language of date format (like month) [message #689450 is a reply to message #689419] Mon, 27 June 2011 16:38 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
Quote:
as a url parameter to
the viewer &__locale=en_US. You can also set locale in script


do u mean I can create a report parameter and set its name as 'locale' and default value = "en_US"?
also, would you mind to tell me how to set locale in script for all element in a report (it is too tired if need set each element locale).
Re: how to control the language of date format (like month) [message #689481 is a reply to message #689450] Mon, 27 June 2011 17:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

No the __locale is a built in viewer parameter. If you set it to a
locale it will set it for all elements.

To set it in script put in a beforeFactory script like:
reportContext.getDesignHandle().setStringProperty("locale",
params["ReportLocale"].value);

Look at the attached example that shows how to do this.

Jason

On 6/27/2011 12:38 PM, forums-noreply@eclipse.org wrote:
> Quote:
>> as a url parameter to
>> the viewer &__locale=en_US. You can also set locale in script
>
>
> do u mean I can create a report parameter and set its name as 'locale'
> and default value = "en_US"?
> also, would you mind to tell me how to set locale in script for all
> element in a report (it is too tired if need set each element locale).
Re: how to control the language of date format (like month) [message #689644 is a reply to message #689481] Tue, 28 June 2011 04:03 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
My eclipse birt plugin version is
Eclipse BIRT Designer Version 2.2.1.r221_v20070924 Build <2.2.0.v20070924-1550
and so cannot run your attachment, but I copy
Quote:

reportContext.getDesignHandle().setStringProperty("locale", params["ReportLocale"].value);

in report beforeFactory method
and
Quote:

<scalar-parameter name="ReportLocale" id="23564029">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<property name="distinct">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
<list-property name="selectionList">
<structure>
<property name="value">de_DE</property>
</structure>
<structure>
<property name="value">fr_FR</property>
</structure>
<structure>
<property name="value">zh_TW</property>
</structure>
<structure>
<property name="value">en_US</property>
</structure>
</list-property>
</scalar-parameter>

inside parameters attribute,
then when I run the report, the locale selection list come out, but whatever value I choose, the date display does not change (chinese, english, france...), why?
is the method not valid in birt version 2.2.1.r221_v20070924?
Re: how to control the language of date format (like month) [message #689878 is a reply to message #689644] Tue, 28 June 2011 14:23 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

In 2.2.1 you have to set it like

reportContext.getReportRunnable().designHandle.getDesignHandle().setStringProperty("locale",params["ReportLocale"]);

I believe.

Jason

On 6/28/2011 12:03 AM, forums-noreply@eclipse.org wrote:
> My eclipse birt plugin version is Eclipse BIRT Designer Version
> 2.2.1.r221_v20070924 Build <2.2.0.v20070924-1550
> and so cannot run your attachment, but I copy
> Quote:
>> reportContext.getDesignHandle().setStringProperty("locale",
>> params["ReportLocale"].value);
>
> in report beforeFactory method
> and Quote:
>> <scalar-parameter name="ReportLocale" id="23564029">
>> <property name="valueType">static</property>
>> <property name="dataType">string</property>
>> <property name="paramType">simple</property>
>> <property name="controlType">list-box</property>
>> <property name="mustMatch">true</property>
>> <property name="fixedOrder">true</property>
>> <property name="distinct">true</property>
>> <structure name="format">
>> <property name="category">Unformatted</property>
>> </structure>
>> <list-property name="selectionList">
>> <structure>
>> <property name="value">de_DE</property>
>> </structure>
>> <structure>
>> <property name="value">fr_FR</property>
>> </structure>
>> <structure>
>> <property name="value">zh_TW</property>
>> </structure>
>> <structure>
>> <property name="value">en_US</property>
>> </structure>
>> </list-property>
>> </scalar-parameter>
>
> inside parameters attribute, then when I run the report, the locale
> selection list come out, but whatever value I choose, the date display
> does not change (chinese, english, france...), why?
> is the method not valid in birt version 2.2.1.r221_v20070924?
Re: how to control the language of date format (like month) [message #690689 is a reply to message #689878] Thu, 30 June 2011 02:40 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
in beforeFactory, I write
try{
reportContext.getReportRunnable().designHandle.getDesignHandle().setStringProperty("locale",params["ReportLocale"]);
Packages.java.lang.System.out.println('params[\"ReportLocale\"]  = ' + params["ReportLocale"]);
}catch(ex){
	Packages.java.lang.System.out.println('Exception in beforeFactory');
}


and in eclipsec.exe, it show
Quote:

Exception in beforeFactory


any documentation to show how to set locale in script in birt designer 2.2.1?
Re: how to control the language of date format (like month) [message #691043 is a reply to message #690689] Thu, 30 June 2011 15:09 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I do not believe 2.2.1 had the locale report property.
Try this beforeFactory script:
importPackage(Packages.java.util);
var loc = new Locale("en_US");
_jsContext.setLocale(loc);

Jason

On 6/29/2011 10:40 PM, forums-noreply@eclipse.org wrote:
> in beforeFactory, I write
>
> try{
> reportContext.getReportRunnable().designHandle.getDesignHandle().setStringProperty("locale",params["ReportLocale"]);
>
> Packages.java.lang.System.out.println('params[\"ReportLocale\"] = ' +
> params["ReportLocale"]);
> }catch(ex){
> Packages.java.lang.System.out.println('Exception in beforeFactory');
> }
>
>
> and in eclipsec.exe, it show
> Quote:
>> Exception in beforeFactory
>
>
> any documentation to show how to set locale in script in birt designer
> 2.2.1?
Re: how to control the language of date format (like month) [message #691886 is a reply to message #691043] Sat, 02 July 2011 17:53 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
I put the following code in beforeFactory
Packages.java.lang.System.out.println ("--beforeFactory");
try{
	importPackage(Packages.java.util);
	Packages.java.lang.System.out.println("after importPackage");
	var loc = new Locale("en_US");
	_jsContext.setLocale(loc);
}catch(ex){
	Packages.java.lang.System.out.println ("error in beforeFactory, locale");
}


in my pc, the output of the report, date format is still in chinese!!
the output and the rptdesign is attached for reference.

My birt designer version is 2.2.1
Re: how to control the language of date format (like month) [message #692030 is a reply to message #691886] Sun, 03 July 2011 08:17 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
I change something in beforeFactory and it is now like the following
Packages.java.lang.System.out.println ("--beforeFactory");
try{
	importPackage(Packages.java.util);
	Packages.java.lang.System.out.println("after importPackage");
	Packages.java.lang.System.out.println("locale = " + reportContext.getLocale().toString());	
	var loc = new Locale("en_US");
	_jsContext.setLocale(loc);
	Packages.java.lang.System.out.println("locale = " + reportContext.getLocale().toString());	
}catch(ex){
	Packages.java.lang.System.out.println ("error in beforeFactory, locale");
}


the output see in eclipsec.exe prompt is
Quote:

--beforeFactory
after importPackage
locale = zh_TW
locale = en_us
this.queryText: select *
from contract_current_salary
where current_salary >= '20000'
order by current_salary;
text onCreate run
text onCreate finish
text onRender run
text onRender finish


it seems the locale is already change to en_us, but the report output is still in chinese format as attach (localeProblem2.jpg)!!
why?

My birt designer version is 2.2.1

[Updated on: Sun, 03 July 2011 08:21]

Report message to a moderator

Re: how to control the language of date format (like month) [message #692134 is a reply to message #692030] Sun, 03 July 2011 17:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

When you add the url parameter &__locale=en_US does that work? If you
are trying this in the designer, open windows->preferences->Report
Design->Preview and click on the Always use external browsers . This
should use your default browser to preview the report. It will also
show the url. The locale parameter may already be in your url, so just
change it.

Jason

On 7/3/2011 4:17 AM, forums-noreply@eclipse.org wrote:
Re: how to control the language of date format (like month) [message #692285 is a reply to message #692134] Mon, 04 July 2011 06:34 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
it does not work.
in my office notebook, the report always show english date format, in contrast of chinese format.
the origin url is
Quote:

http://127.0.0.1:59742/viewer/frameset?__report=C%3A%5CEric%5CHKCustom%5CDEV%5Cworkspace%5CCommon+Reporting%5CCCS%5CSituations%5CACCS00005%5CACCS00005_Situations_History.rptdesign&__format=html&__svg=false&__designer=true&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%2FEric%2FHKCustom%2FDEV%2Fworkspace%2FCommon+Reporting%2Fresources%2F&-1561881804


no any locale parameter, I try to add &_locale=zh_TW in the url and refresh
Quote:

http://127.0.0.1:59742/viewer/frameset?__report=C%3A%5CEric%5CHKCustom%5CDEV%5Cworkspace%5CCommon+Reporting%5CCCS%5CSituations%5CACCS00005%5CACCS00005_Situations_History.rptdesign&__format=html&__svg=false&__designer=true&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%2FEric%2FHKCustom%2FDEV%2Fworkspace%2FCommon+Reporting%2Fresources%2F&-1561881804&_locale=zh_TW

but the date format is still in english, so it seems that _locale parameter in url has no effect on the datae format in the report...

My birt designer version is 2.2.1

[Updated on: Mon, 04 July 2011 06:36]

Report message to a moderator

Re: how to control the language of date format (like month) [message #693028 is a reply to message #688201] Tue, 05 July 2011 16:27 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
anyone has idea about how to set locale (or date format for all elements in reports) through script?
or it is really a limitation in birt 2.2.1?
Re: how to control the language of date format (like month) [message #693038 is a reply to message #692285] Tue, 05 July 2011 16:46 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I just tried this script in the beforeFactory:

importPackage(Packages.java.util);
var loc = new Locale("zh_TW");
_jsContext.setLocale(loc);

In BIRT 2.2.1 and then I added a data element to the report with the
value of new Date();

and it works for me.

Jason


On 7/4/2011 2:34 AM, forums-noreply@eclipse.org wrote:
> it does not work.
> in my office notebook, the report always show english date format, in contrast of chinese format.
> the origin url is
> Quote:
>> http://127.0.0.1:59742/viewer/frameset?__report=C%3A%5CEric%5CHKCustom%5CDEV%5Cworkspace%5CCommon+Reporting%5CCCS%5CSituations%5CACCS00005%5CACCS00005_Situations_History.rptdesign&__format=html&__svg=false&__designer=true&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%2FEric%2FHKCustom%2FDEV%2Fworkspace%2FCommon+Reporting%2Fresources%2F&-1561881804
>
>
> no any locale parameter, I try to add&_locale=zh_TW in the url and refresh
> Quote:
>> http://127.0.0.1:59742/viewer/frameset?__report=C%3A%5CEric%5CHKCustom%5CDEV%5Cworkspace%5CCommon+Reporting%5CCCS%5CSituations%5CACCS00005%5CACCS00005_Situations_History.rptdesign&__format=html&__svg=false&__designer=true&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%2FEric%2FHKCustom%2FDEV%2Fworkspace%2FCommon+Reporting%2Fresources%2F&-1561881804&_locale=zh_TW
>
> but the date format is still in english, so it seems that _locale parameter in url has no effect on the datae format in the report...
Re: how to control the language of date format (like month) [message #693194 is a reply to message #693038] Wed, 06 July 2011 01:57 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
could you post the rptdesign file for me?
I think, will the database record has effect on the output?

I try the method you mention in Sun, 03 July 2011 04:17 post and it seems the locale is already change to en_us, but the report output is still in chinese format as attach (localeProblem2.jpg)!!
Re: how to control the language of date format (like month) [message #693663 is a reply to message #693194] Thu, 07 July 2011 00:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I currently do not have access to my 2.2.1 install, but the report only
contained a data item with an expression of new Date() field.

Jason


On 7/5/2011 9:57 PM, forums-noreply@eclipse.org wrote:
> could you post the rptdesign file for me?
> I think, will the database record has effect on the output?
>
> I try the method you mention in Sun, 03 July 2011 04:17 post and it
> seems the locale is already change to en_us, but the report output is
> still in chinese format as attach (localeProblem2.jpg)!!
Re: how to control the language of date format (like month) [message #695325 is a reply to message #693663] Mon, 11 July 2011 13:56 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
I already spend many time on this problem but still cannot get a solution.
I just follow your suggestion, add code
importPackage(Packages.java.util);
//var loc = new Locale("zh_TW");
var loc = new Locale("en_us");
_jsContext.setLocale(loc);

and add a dataelement, then view report in web viewer, the output is still in chinese date format as attached!!

my birt designer version is 2.2.1

Could you provide a successful sample for me, one for chinese date format (e.g. zh_TW ) and the other for english date format (e.g. en_US) using birt designer 2.2.1?
Re: how to control the language of date format (like month) [message #695351 is a reply to message #695325] Mon, 11 July 2011 15:00 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
after a painful try and error, I think where is the problem now. the code should placed in "initialize" event instead of "beforeFactory" event, at least for birt designer 2.2.1.

Re: how to control the language of date format (like month) [message #695597 is a reply to message #695351] Tue, 12 July 2011 05:21 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I am glad you got this working. Sorry it was so painful.

Jason

On 7/11/2011 11:00 AM, forums-noreply@eclipse.org wrote:
> after a painful try and error, I think where is the problem now. the code should placed in "initialize" event instead of "beforeFactory" event, at least for birt designer 2.2.1.
>
>
Previous Topic:BIRT crashes on Mac OS X Snow Leopard
Next Topic:Multiple questions on BIRT engine
Goto Forum:
  


Current Time: Fri Apr 19 23:57:03 GMT 2024

Powered by FUDForum. Page generated in 0.04122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top