You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Alex V. Alishevskikh" <al...@openmechanics.net> on 2002/03/22 10:07:05 UTC

AWTRenderer L10N issues

Hi, there,

I've found what "messages.ru" file is missing in the AWT Renderer resources. As a result, AWTStarter crashes with NullPointerException on launching it on russian system.

The another issue is wrong encoding in "resources.ru" file (it looks like 8859-1), what makes the cyrillic labels and menus are unreadable.

I've created the messages.ru and resources.ru files with russian text in UTF-8 (see attached files). It seems what it works well (FOP 0.20.3, Sun JDK 1.3.0). 

I wish to propose the solution for case when AWTStarter cannot finds the resource bundle appropriated for user language: then let it to use the english (*.en) resources as default.
It would be look like as:
(at org.apache.fop.apps.AWTStarter.getResourceBundle() )

...
URL url = getClass().getResource(path);
if (url == null) {
 path = path.substring(0, path.lastIndexOf(".")) + ".en";
 url = getClass().getResource(path);
}
in = url.openStream();
...

(See attached AWTStarter.java)

It should prevent the crashes on machines with language settings are unsupported in AWT renderer resources. Any opinions?


Best regards,
Alex V. Alishevskikh <al...@openmechanics.net>

OpenMechanics
http://www.openmechanics.net

Re: AWTRenderer L10N issues

Posted by Patrick Andries <pa...@videotron.ca>.

Patrick Andries wrote:

> Christian Geisert wrote:
>
>> Alex V. Alishevskikh wrote:
>>
>>> Hi, there,
>>>
>>> I've found what "messages.ru" file is missing in the AWT Renderer 
>>> resources. As a result, AWTStarter crashes with NullPointerException 
>>> on launching it on russian system.
>>>
>>> The another issue is wrong encoding in "resources.ru" file (it looks 
>>> like 8859-1 ), what makes the cyrillic labels and menus are unreadable. 
>>
>>
> No, it was coded in 8859-5 (Cyrillic) or Windows 1251, I can see 
> "File=<f><a><i><l>" Файл. You most probably compiled on a non-Cyrillic 
> machine and did not set -encoding javac compilation option. I believe 
> your change is, however, a good one. 


Forget the -encoding javac compilation option, this is for 
ListResourceBundle. It's getting late.

P. Andries





---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AWTRenderer L10N issues

Posted by Satoshi Ishigami <is...@victokai.co.jp>.
Hi , All !!

Since FOP-0.20.3, the encoding of configuration files for 
AWTViewer was changed to UTF-8.

These files may not be ISO8859-1 with Unicode escapes format
because they are accessed with InputStreamReader.

You can found this implementation in
org.apache.fop.viewer.LoadableProperties (this class is 
instanciated in org.apache.fop.viewer.SecureResourceBundle).

Therefore you must write any configuration files (for examples,
resources.ru and messages.ru) by UTF-8 encoding.

Regards.
---
Satoshi Ishigami   VIC TOKAI CORPORATION


On Tue, 26 Mar 2002 13:17:26 +0500 , Alex V. Alishevskikh wrote:

> Hi, Patrick,
> 
> You wrote:
> > No, it was coded in 8859-5 (Cyrillic) or Windows 1251,
> 
> AFAIK, ISO8859-5 is not the same that Windows 1251. I see the extended latin
> letters (with umlauts etc) instead of cyrillic characters.
> I've compiled FOP on machine (WinXP, Sun JDK 1.3) with russian locale.
> 
> > ? The only encoding that Properties and PropertyResourceBundle
> > understand is ISO 8859-1 with Unicode escapes. This is not UTF-8.
> 
> But why my Properties encoded as UTF-8 works and I see the readable russian
> text?
> 
> 
> ----- Original Message -----
> From: "Patrick Andries" <pa...@videotron.ca>
> To: <fo...@xml.apache.org>
> Sent: Sunday, March 24, 2002 9:59 AM
> Subject: Re: AWTRenderer L10N issues
> 
> 
> > Christian Geisert wrote:
> >
> > > Alex V. Alishevskikh wrote:
> > >
> > >> Hi, there,
> > >>
> > >> I've found what "messages.ru" file is missing in the AWT Renderer
> > >> resources. As a result, AWTStarter crashes with NullPointerException
> > >> on launching it on russian system.
> > >>
> > >> The another issue is wrong encoding in "resources.ru" file (it looks
> > >> like 8859-1 ), what makes the cyrillic labels and menus are unreadable.
> > >
> > No, it was coded in 8859-5 (Cyrillic) or Windows 1251, I can see
> > "File=<f><a><i><l>" 譱別. You most probably compiled on a non-Cyrillic
> > machine and did not set -encoding javac compilation option. I believe
> > your change is, however, a good one.
> >
> > I notice you also change some translations.(About, Show, etc.).
> > .
> >
> > >>
> > >>
> > >> I've created the messages.ru and resources.ru files with russian text
> > >> in UTF-8 (see attached files). It seems what it works well (FOP
> > >> 0.20.3, Sun JDK 1.3.0).
> > >
> > Did you use Unicode escape sequences (with native2ascii) ? If not, I'm
> > not sure it works all the time (might because of BOM).
> >
> > ? The only encoding that Properties and PropertyResourceBundle
> > understand is ISO 8859-1 with Unicode escapes. This is not UTF-8. UTF-8
> > encodes Unicode characters into sequences of 1 to 4 bytes using a
> > mapping specified in The Unicode Standard, version 2.0 or 3.0. Other
> > encodings need to be converted with the native2ascii tool. This applies
> > to all releases from 1.1 to 1.3. ?
> > http://www.sun.com/developers/gadc/faq/java/files/properties.html#2.0
> >
> > >>
> > >> I wish to propose the solution for case when AWTStarter cannot finds
> > >> the resource bundle appropriated for user language: then let it to
> > >> use the english (*.en) resources as default.
> > >
> > >
> > > [..]
> > >
> > >> It should prevent the crashes on machines with language settings are
> > >> unsupported in AWT renderer resources. Any opinions?
> > >
> > I wonder if this is a good idea.
> >
> > Why not use whatever is in the default resourceBundle ? Hardcoding seems
> > useless at best when there is a more flexible built-in mechanism
> > (getBundle search).
> > However, it looks like this mechanism is short-circuited in AWTStarter
> > by using a ResourceBundle name that incorporates the language ("
> > resource = getResourceBundle(TRANSLATION_PATH + "resources." +
> > language)") and does not set any Locale. I do not believe this to be wise.
> >
> > This is an i18n issue.
> >
> > P. Andries
> > -----------
> >
> > Tout Unicode 3.1 en franc,ais
> > http://hapax.iquebec.com
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> > For additional commands, email: fop-dev-help@xml.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AWTRenderer L10N issues

Posted by "Alex V. Alishevskikh" <al...@openmechanics.net>.
Hi, Patrick,

>I only regret that using this new getResourceBundle, it looks like the
standard getBundle search algorithm is not implemented. I personnaly believe
it is usually bad >design to hardcode a default language,  One should rather
use  a Locale for setting the language (picked from the argv for instance)
or getting the platform's default >one and rely on the getBundle algorithm.
The default resource language could then become the platform's language
(locale) unless no resource exist for it, in which >case the resources found
in the base resource bundle could be used (this could be a different file
for each system according to installation option).

I agree. This is better than my proposals.

Ive found the old message from  Satoshi Ishigami, Jan 28, 2002 (see below)
and he says the same.
Satoshi wrote:

> The language to use on AWTViewer is decided by getting the
> system default or specifying -l option. The decided language
> is used for the suffix of resource files. However Java has
> a feature that access to a resource file for every language
> by default (i.e. java.util.ResourceBundle class and
> for examples rsources_ja.properties).

Also  I've understood why the resources.ru file was in that strange
encoding.
Satoshi wrote:

> I also convert all existed resource file for AWTViewer from
> iso-8859-1 to UTF-8 automatically.

resources.ru was in the iso-8859-5 (as you says), not in the iso-8859-1. And
it was converted to UTF-8, supposed what the primary encoding is 8859-1.
Because of this I saw the european additional letters (from 8859-1) instead
of cyrillic. It could happened with every 8859-x (not -1) encoded resource,
if it was presents there.

The full text of Satoshi Ishigami message:
----- Original Message -----
From: "Satoshi Ishigami" <is...@victokai.co.jp>
To: <fo...@xml.apache.org>
Sent: Monday, January 28, 2002 4:32 AM
Subject: i18n in awt viewer [PATCH]


>
> Hi all !
>
> For AWTViewer i18n, I hacked the AWTViewer for FOP-0.23.0rc
> maintenance release and I had some questions.
>
> I tried to show the menu as Japanese text for i18n for trial.
> I wrote the resource files by UTF-8 encoding because it is not
> possible to map multi-bytes characters by iso-8859-1 encoding.
> I also convert all existed resource file for AWTViewer from
> iso-8859-1 to UTF-8 automatically.
>
> I modified some source files associated with AWTViewer, too.
> This modification is for the message i18n and for additional
> fonts support on AWTViewer.
>
> The additional fonts are specified in a userconfig.xml file.
> And you may start FOP with -c and -awt options. NOTE:Now the
> additional fonts that you can specified is only TrueType font
> (.ttf and .ttc). This restriction comes from the feature of
> SUN's JDK (see java.awt.Font javadoc).
>
> 1) If you specify the embed-file attribute in userconfig.xml
> and use JDK1.3 or higher, the specified TrueType font is loaded
> and used in AWTViewer.
>
> 2) Otherwise, if you don't specify the embed-file attribute or
> use JDK1.2, the additional font is regarded as Java's "Dialog"
> logical font name for each Locale.
>
> I attempt to show Japanese fo file. My test environment is:
> SUN's JDK1.2.2 and JDK1.3. LANG=EN and JA environment variable.
>
> When use LANG=JA, 1) and 2) are works fine (menu is Japanese
> text and the represented document is readable).
>
> LANG=EN and 1) also works fine (menu is English text and
> document readable). But the convination of LANG=EN and 2) does
> not works fine (menu looks English text well but document is
> unreadble). However I think that this behavior is right.
>
>
> Below is my questions.
>
> Currently the text of menu for the AWTViewer is loaded from
> org.apache.fop.viewer.resources package. The AWTViewer needs
> two kinds of resource file (messages.lang and resources.lang).
>
> I can not found messages.lang file for some languages (fi,fr,
> it,pl.ru). Therefore the following command can not start the
> AWTViewer (thrown NPE).
>
> fop -awt -l fi foo.fo
>
> Q1.Is not messages.lang file necessary with resources.lang file?
>
>
> The language to use on AWTViewer is decided by getting the
> system default or specifying -l option. The decided language
> is used for the suffix of resource files. However Java has
> a feature that access to a resource file for every language
> by default (i.e. java.util.ResourceBundle class and
> for examples rsources_ja.properties).
>
> Currently AWTViewer regards resource files as written by
> iso-8859-1 encoding. This is not good for i18n. I converted
> them to UTF-8 encoding, but I think that the ResourceBundle
> framework is better than now because AWTViewer can start
> even if there are not resource files for any languages.
>
> Q2.Why AWTViewer does not use ResourceBundle?
>
> Best Regards.
>
> ---
> $B@P?@(B $B3P;J(B(Satoshi Ishigami)   VIC TOKAI CORPORATION
>





----- Original Message -----
From: Patrick Andries
To: fop-dev@xml.apache.org
Sent: Tuesday, March 26, 2002 6:09 PM
Subject: Re: AWTRenderer L10N issues




Alex V. Alishevskikh wrote:

Hi, Patrick,You wrote:
No, it was coded in 8859-5 (Cyrillic) or Windows 1251,
AFAIK, ISO8859-5 is not the same that Windows 1251.

Well, Microsoft adds to 8859-5 a few Cyrillic characters in the 80-9F range
(euro sign for one,  and diacritic forms such as k apostrophe on top).
My point was rather that it was not 8859-1 as mentioned but 8859-5 or CP
1251 which are hard to distinguish.


 I see the extended latinletters (with umlauts etc) instead of cyrillic
characters.I've compiled FOP on machine (WinXP, Sun JDK 1.3) with russian
locale.
? The only encoding that Properties and PropertyResourceBundleunderstand is
ISO 8859-1 with Unicode escapes. This is not UTF-8.
But why my Properties encoded as UTF-8 works and I see the readable
russiantext?
As pointed out in a different message by Satoshi, and I missed this,
AWTStarter uses a getResourceBundle which in turns uses a
SecourceResourceBundle that reads UTF-8 (I still see 8859-1 in my source). I
suppose I should update my tree.
I only regret that using this new getResourceBundle, it looks like the
standard getBundle search algorithm is not implemented. I personnaly believe
it is usually bad design to hardcode a default language,  One should rather
use  a Locale for setting the language (picked from the argv for instance)
or getting the platform's default one and rely on the getBundle algorithm.
The default resource language could then become the platform's language
(locale) unless no resource exist for it, in which case the resources found
in the base resource bundle could be used (this could be a different file
for each system according to installation option).

P. Andries


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AWTRenderer L10N issues

Posted by Patrick Andries <pa...@videotron.ca>.

Alex V. Alishevskikh wrote:

>Hi, Patrick,
>
>You wrote:
>
>>No, it was coded in 8859-5 (Cyrillic) or Windows 1251,
>>
>
>AFAIK, ISO8859-5 is not the same that Windows 1251.
>

Well, Microsoft adds to 8859-5 a few Cyrillic characters in the 80-9F 
range (euro sign for one,  and diacritic forms such as k apostrophe on top).
My point was rather that it was not 8859-1 as mentioned but 8859-5 or CP 
1251 which are hard to distinguish.

> I see the extended latin
>letters (with umlauts etc) instead of cyrillic characters.
>I've compiled FOP on machine (WinXP, Sun JDK 1.3) with russian locale.
>
>>? The only encoding that Properties and PropertyResourceBundle
>>understand is ISO 8859-1 with Unicode escapes. This is not UTF-8.
>>
>
>But why my Properties encoded as UTF-8 works and I see the readable russian
>text?
>
As pointed out in a different message by Satoshi, and I missed this,  
AWTStarter uses a getResourceBundle which in turns uses a 
SecourceResourceBundle that reads UTF-8 (I still see 8859-1 in my 
source). I suppose I should update my tree.

I only regret that using this new getResourceBundle, it looks like the 
standard getBundle search algorithm is not implemented. I personnaly 
believe it is usually bad design to hardcode a default language,  One 
should rather use  a Locale for setting the language (picked from the 
argv for instance) or getting the platform's default one and rely on the 
getBundle algorithm. The default resource language could then become the 
platform's language (locale) unless no resource exist for it, in which 
case the resources found in the base resource bundle could be used (this 
could be a different file for each system according to installation option).

P. Andries



Re: AWTRenderer L10N issues

Posted by "Alex V. Alishevskikh" <al...@openmechanics.net>.
Hi, Patrick,

You wrote:
> No, it was coded in 8859-5 (Cyrillic) or Windows 1251,

AFAIK, ISO8859-5 is not the same that Windows 1251. I see the extended latin
letters (with umlauts etc) instead of cyrillic characters.
I've compiled FOP on machine (WinXP, Sun JDK 1.3) with russian locale.

> ? The only encoding that Properties and PropertyResourceBundle
> understand is ISO 8859-1 with Unicode escapes. This is not UTF-8.

But why my Properties encoded as UTF-8 works and I see the readable russian
text?


----- Original Message -----
From: "Patrick Andries" <pa...@videotron.ca>
To: <fo...@xml.apache.org>
Sent: Sunday, March 24, 2002 9:59 AM
Subject: Re: AWTRenderer L10N issues


> Christian Geisert wrote:
>
> > Alex V. Alishevskikh wrote:
> >
> >> Hi, there,
> >>
> >> I've found what "messages.ru" file is missing in the AWT Renderer
> >> resources. As a result, AWTStarter crashes with NullPointerException
> >> on launching it on russian system.
> >>
> >> The another issue is wrong encoding in "resources.ru" file (it looks
> >> like 8859-1 ), what makes the cyrillic labels and menus are unreadable.
> >
> No, it was coded in 8859-5 (Cyrillic) or Windows 1251, I can see
> "File=<f><a><i><l>" Файл. You most probably compiled on a non-Cyrillic
> machine and did not set -encoding javac compilation option. I believe
> your change is, however, a good one.
>
> I notice you also change some translations.(About, Show, etc.).
> .
>
> >>
> >>
> >> I've created the messages.ru and resources.ru files with russian text
> >> in UTF-8 (see attached files). It seems what it works well (FOP
> >> 0.20.3, Sun JDK 1.3.0).
> >
> Did you use Unicode escape sequences (with native2ascii) ? If not, I'm
> not sure it works all the time (might because of BOM).
>
> ? The only encoding that Properties and PropertyResourceBundle
> understand is ISO 8859-1 with Unicode escapes. This is not UTF-8. UTF-8
> encodes Unicode characters into sequences of 1 to 4 bytes using a
> mapping specified in The Unicode Standard, version 2.0 or 3.0. Other
> encodings need to be converted with the native2ascii tool. This applies
> to all releases from 1.1 to 1.3. ?
> http://www.sun.com/developers/gadc/faq/java/files/properties.html#2.0
>
> >>
> >> I wish to propose the solution for case when AWTStarter cannot finds
> >> the resource bundle appropriated for user language: then let it to
> >> use the english (*.en) resources as default.
> >
> >
> > [..]
> >
> >> It should prevent the crashes on machines with language settings are
> >> unsupported in AWT renderer resources. Any opinions?
> >
> I wonder if this is a good idea.
>
> Why not use whatever is in the default resourceBundle ? Hardcoding seems
> useless at best when there is a more flexible built-in mechanism
> (getBundle search).
> However, it looks like this mechanism is short-circuited in AWTStarter
> by using a ResourceBundle name that incorporates the language ("
> resource = getResourceBundle(TRANSLATION_PATH + "resources." +
> language)") and does not set any Locale. I do not believe this to be wise.
>
> This is an i18n issue.
>
> P. Andries
> -----------
>
> Tout Unicode 3.1 en franc,ais
> http://hapax.iquebec.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AWTRenderer L10N issues

Posted by Patrick Andries <pa...@videotron.ca>.
Christian Geisert wrote:

> Alex V. Alishevskikh wrote:
>
>> Hi, there,
>>
>> I've found what "messages.ru" file is missing in the AWT Renderer 
>> resources. As a result, AWTStarter crashes with NullPointerException 
>> on launching it on russian system.
>>
>> The another issue is wrong encoding in "resources.ru" file (it looks 
>> like 8859-1 ), what makes the cyrillic labels and menus are unreadable. 
>
No, it was coded in 8859-5 (Cyrillic) or Windows 1251, I can see 
"File=<f><a><i><l>" Файл. You most probably compiled on a non-Cyrillic 
machine and did not set -encoding javac compilation option. I believe 
your change is, however, a good one.

I notice you also change some translations.(About, Show, etc.).
.

>>
>>
>> I've created the messages.ru and resources.ru files with russian text 
>> in UTF-8 (see attached files). It seems what it works well (FOP 
>> 0.20.3, Sun JDK 1.3.0).
>
Did you use Unicode escape sequences (with native2ascii) ? If not, I'm 
not sure it works all the time (might because of BOM).

? The only encoding that Properties and PropertyResourceBundle 
understand is ISO 8859-1 with Unicode escapes. This is not UTF-8. UTF-8 
encodes Unicode characters into sequences of 1 to 4 bytes using a 
mapping specified in The Unicode Standard, version 2.0 or 3.0. Other 
encodings need to be converted with the native2ascii tool. This applies 
to all releases from 1.1 to 1.3. ?
http://www.sun.com/developers/gadc/faq/java/files/properties.html#2.0

>>
>> I wish to propose the solution for case when AWTStarter cannot finds 
>> the resource bundle appropriated for user language: then let it to 
>> use the english (*.en) resources as default.
>
>
> [..]
>
>> It should prevent the crashes on machines with language settings are 
>> unsupported in AWT renderer resources. Any opinions?
>
I wonder if this is a good idea.

Why not use whatever is in the default resourceBundle ? Hardcoding seems 
useless at best when there is a more flexible built-in mechanism 
(getBundle search).
However, it looks like this mechanism is short-circuited in AWTStarter 
by using a ResourceBundle name that incorporates the language (" 
resource = getResourceBundle(TRANSLATION_PATH + "resources." + 
language)") and does not set any Locale. I do not believe this to be wise.

This is an i18n issue.

P. Andries
-----------

Tout Unicode 3.1 en franc,ais
http://hapax.iquebec.com



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AWTRenderer L10N issues

Posted by Christian Geisert <ch...@isu-gmbh.de>.
Alex V. Alishevskikh wrote:
> Hi, there,
> 
> I've found what "messages.ru" file is missing in the AWT Renderer 
> resources. As a result, AWTStarter crashes with NullPointerException on 
> launching it on russian system.
> 
> The another issue is wrong encoding in "resources.ru" file (it looks 
> like 8859-1), what makes the cyrillic labels and menus are unreadable.
> 
> I've created the messages.ru and resources.ru files with russian text in 
> UTF-8 (see attached files). It seems what it works well (FOP 0.20.3, Sun 
> JDK 1.3.0).
> 
> I wish to propose the solution for case when AWTStarter cannot finds the 
> resource bundle appropriated for user language: then let it to use the 
> english (*.en) resources as default.

[..]

> It should prevent the crashes on machines with language settings are 
> unsupported in AWT renderer resources. Any opinions?

Sounds good, I will have a closer look at it on the weekend.

> Best regards,
> Alex V. Alishevskikh <alex@openmechanics.net 

Christian


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org