lyonplus / gettext-commons

Automatically exported from code.google.com/p/gettext-commons
GNU Lesser General Public License v2.1
0 stars 0 forks source link

I18n.trc() returns untranslated comment for code Locale "en" and base (ROOT) ResourceBundle #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

I18n.trc() will produce wrong (default) translations in the following
situation:

1. code Locale is "en"

2. used ResourceBundle is ROOT locale (i18n.Messages) - fallback from
non-existing i18n.Messages_en - but the I18n Locale language is "en"

3. I18n.trc() will check if text or translated comment should be used, and
for this uses the bundle's locale to determine if it's the same as the code
locale. 
As those are different (ROOT vs "en"), I18n.tr() will be invoked for the
default bundle with the comment instead of the text, which is not
translated but returned as is (ie. "boot (noun)" instead of "boot")

What version of the product are you using? On what operating system?

gettext-commons 0.9.2 with ant-tasks 0.9.3
 on WindowsXP with Eclipse 3.4.1.

Please provide any additional information below.

Problem here is, that the I18n that is returned by the factory has the
locale "en", but the actual ResourceBundle is the base, ROOT Locale. 

A possible fix, as far as I see, would be:

Ask for the I18n's Locale instead of the bundle's in I18n, line 488:

current:
return sourceCodeLocale.equals(getResources().getLocale()) ? text :
tr(comment);

fixed:
return sourceCodeLocale.equals(getLocale()) ? text : tr(comment);

I'm not sure if this would have other side effects. Maybe its also just me
using a wrong Locale set for the default Bundle?

Original issue reported on code.google.com by tobiaskr...@gmail.com on 13 Nov 2008 at 9:12

GoogleCodeExporter commented 8 years ago
A possible workaround (or maybe its even intended to work like this?) is:

using I18n.setSourceCodeLocale() method to set the source locale to Locale.ROOT

Original comment by tobiaskr...@gmail.com on 13 Nov 2008 at 9:25

GoogleCodeExporter commented 8 years ago
This has been fixed in svn and is part of release version 0.9.5.

Original comment by berge...@gmail.com on 11 Feb 2009 at 4:26

GoogleCodeExporter commented 8 years ago
Super, vielen Dank!

Original comment by supremac...@googlemail.com on 11 Feb 2009 at 12:02