DO NOT REPLY [Bug 17715] - [PATCH] JetspeedLocalizationService only looks at first resource bundle
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715 [PATCH] JetspeedLocalizationService only looks at first resource bundle [EMAIL PROTECTED] changed: What|Removed |Added AssignedTo|jetspeed- |[EMAIL PROTECTED] |[EMAIL PROTECTED] | Status|REOPENED|NEW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 17715] - [PATCH] JetspeedLocalizationService only looks at first resource bundle
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715 [PATCH] JetspeedLocalizationService only looks at first resource bundle --- Additional Comments From [EMAIL PROTECTED] 2003-03-14 17:56 --- This patch fixed the issue I was having. The the following thread for details. http://marc.theaimsgroup.com/?l=jetspeed-user&m=104751540406520&w=2 +1 on getting this patch into CVS! Thanks a million Jon :-) Jake - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 17715] - [PATCH] JetspeedLocalizationService only looks at first resource bundle
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17715 [PATCH] JetspeedLocalizationService only looks at first resource bundle [EMAIL PROTECTED] changed: What|Removed |Added Summary|JetspeedLocalizationService |[PATCH] |only looks at first resource|JetspeedLocalizationService |bundle |only looks at first resource ||bundle Target Milestone|1.4b2 |1.4b4 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [patch] JetspeedLocalizationService
Massimiliano Dessì wrote: The language changes at runtime. It does if you only have 1 resource bundle. I don't understand your problem with the change language. Try this. Put this in your TurbineResources.properties: locale.default.bundles=bundle.test, \ org.apache.jetspeed.modules.localization.JetspeedLocalization and create a new file WEB-INF/classes/bundle/test.properties, containing one useless line: hello=world Now try and load the site (configured to use JetspeedLocalizationService). Note that the $i10n.KEY statements *should* still work, because they will check the org.apache.jetspeed.modules.localization.JetspeedLocalization properties file(s) after failing to get the key from bundle.test. However if you do try it I bet you don't get any localized strings because JLS throws a NullPointerException when it tries to look past the first bundle. I was finding that the site worked fine (all of the strings in the content came from my bundle) but when I went to the new user registration page I got the NPE because it was trying to look in the second bundle. The standard TurbineLocalizationService works fine but then of course you can't change the language on the fly. Also the other point of my patch was that it is a waste of time extending another class and then reimplementing every method with a call to super.. Test this file and send a feedback to me , in this way i can help you I can see how your filter works, will this be the new way? The only thing I would add is a check for user!=null before the call to user.setPerm(). Jon -- Merlin Information Systems Limited, Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN Tel: +44 (0) 1280 824331 Fax: +44 (0) 1280 824112 http://www.misgl.com Provider of IT Services and Online Portal Support Services. Confidentiality: The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the information in it by any other person is not authorised. If you are not the intended recipient, please notify us immediately by telephone or by e-mail to [EMAIL PROTECTED] *** This mail has been scanned for viruses *** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [patch] JetspeedLocalizationService
Jon Evans wrote: Hi David, David Sean Taylor wrote: The patch isn't necessary I just committed a patch from Missimilliano Dessi. It works fine as is. Although I thought we had country flag icons with the original portlet. I have just got round to using the latest CVS. I like the fact that the changeLanguage portlet is now a .vm, it will make it a lot easier to change the look and feel for my site. I'm still concerned though with org.apache.jetspeed.services.customlocalization.JetspeedLocalizationService. It still doesn't seem to work if you have more than one bundle defined in locale.default.bundles. It only seems to look at the first bundle. If you look at the class, it extends TurbineLocalizationService. JetspeedLocalizationService implements an initBundleNames() method which populates an instance variable String[] bundleNames. But all of the getString(...) methods call super.getString(...), where TurbineLocalizationService will use its own instance variables and will not find the strings. Let me put it another way. Each class defines an identical set of instance variables, like this: JetspeedLocalizationService TurbineLocalizationService === === private Hashtable bundles; private Hashtable bundles; private String bundleNames[]; private String bundleNames[]; private Locale defaultLocale; private Locale defaultLocale; private String defaultLanguage; private String defaultLanguage; private String defaultCountry; private String defaultCountry; After JetspeedLocalizationService.init() is called they look like this: JetspeedLocalizationService TurbineLocalizationService === == bundles null bundles set bundleNames[]setbundleNames[] null defaultLocalenull defaultLocale set defaultLanguage null defaultLanguage set defaultCountry null defaultCountry set when getString(String bundleName, Locale locale, String key) is called in JetspeedLocalizationService, it calls super.getString(...). This calls getBundle(String, Locale), which is implemented in JetspeedLocalizationService as a call to super.getBundle(String, Locale), so we are back to the code in TurbineLocalizationService. getBundle(String, Locale) in TurbineLocalizationService returns the default bundle to the getString(...) method. Back in getString(String bundleName, Locale locale, String key), we look up the requested key in the bundle, using getStringOrNull(), which returns null because the string I'm looking for isn't in the first bundle, it's in the second. The next test is intended to determine whether we need to check the other bundles for the key. The test is: // Look for text in list of default bundles. if (value == null && bundleNames.length > 0) At this point we throw a NullPointerException because bundleNames is null (it was never set in TurbineLocalizationService, only in JetspeedLocalizationService). The whole of the JetspeedLocalizationService class can be reduced to a single function, getLocale(RunData runData). The attached patch does this, and seems to work. Yes, I compiled from clean this time. :-) Jon It looks right, and removes a lot of code (I have no time to test it), but... In the process of evolution that is coming towards us (I mean JSR results, etc.) it is quite possible that changes are needed, looking from the original proposal and industry trends. So, I would prefer a tested patch which would just stopped inheriting from the turbine one but is still functionally complete. I mean inheriting from TurbineBaseService, which limits dependency to initialization code. I say so because Turbine is moving towards less coupled classes. Currently services are being decoupled and ported to fulcrum, for use in turbine 2.2+ and 3. So I think keeping the whole implementation here until we ensure that the needed changes are in Turbine does not look bad. The way I propose will make easier in the future: * backport our needed functionality to the service already present in Fulcrum * just change the interfaces it implements and have it running in Fulcrum, through the magics of Avalon. Regards, Santiago Index: src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java === RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java,v retrieving revision 1.4 diff -u -r1.4 JetspeedLocalizationService.java --- src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 26 Feb 2003 17:46:34 - 1.4 +++ src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 4 Mar 2003 12:49:37 - @@ -62,14 +62,10 @@ */
Re: [patch] JetspeedLocalizationService
Attached to the mail is the new version portlet to change the language with a servlet filter, the turbine resources.prop to enable the jetspeed Localization Service and localization tool and a diagram to explain the flow. I have modified the Localization service only to change the language witout the browser role (language header). The language changes at runtime. I don't understand your problem with the change language. Test this file and send a feedback to me , in this way i can help you Massimiliano --- Jon Evans <[EMAIL PROTECTED]> ha scritto: > Hi David, > > David Sean Taylor wrote: > > > The patch isn't necessary I just committed a patch > from > > Missimilliano Dessi. It works fine as is. Although > I thought we had > > country flag icons with the original portlet. > > I have just got round to using the latest CVS. I > like the fact that > the changeLanguage portlet is now a .vm, it will > make it a lot easier > to change the look and feel for my site. > > I'm still concerned though with > org.apache.jetspeed.services.customlocalization.JetspeedLocalizationService. > > It still doesn't seem to work if you have more than > one bundle defined > in locale.default.bundles. It only seems to look at > the first bundle. > > If you look at the class, it extends > TurbineLocalizationService. > JetspeedLocalizationService implements an > initBundleNames() method > which populates an instance variable String[] > bundleNames. But all of > the getString(...) methods call > super.getString(...), where > TurbineLocalizationService will use its own instance > variables and will > not find the strings. > > > Let me put it another way. Each class defines an > identical set of > instance variables, like this: > > JetspeedLocalizationService > TurbineLocalizationService > === > === > private Hashtable bundles; private Hashtable > bundles; > private String bundleNames[]; private String > bundleNames[]; > private Locale defaultLocale; private Locale > defaultLocale; > private String defaultLanguage; private String > defaultLanguage; > private String defaultCountry; private String > defaultCountry; > > After JetspeedLocalizationService.init() is called > they look like this: > > JetspeedLocalizationService > TurbineLocalizationService > === > == > bundles null bundles set > bundleNames[]setbundleNames[] null > defaultLocalenull defaultLocale set > defaultLanguage null defaultLanguage set > defaultCountry null defaultCountry set > > when getString(String bundleName, Locale locale, > String key) is called > in JetspeedLocalizationService, it calls > super.getString(...). This > calls getBundle(String, Locale), which is > implemented in > JetspeedLocalizationService as a call to > super.getBundle(String, > Locale), so we are back to the code in > TurbineLocalizationService. > > getBundle(String, Locale) in > TurbineLocalizationService returns the > default bundle to the getString(...) method. > > Back in getString(String bundleName, Locale locale, > String key), we > look up the requested key in the bundle, using > getStringOrNull(), which > returns null because the string I'm looking for > isn't in the first > bundle, it's in the second. > > The next test is intended to determine whether we > need to check the > other bundles for the key. The test is: > > // Look for text in list of default > bundles. > if (value == null && bundleNames.length > > 0) > > At this point we throw a NullPointerException > because bundleNames is > null (it was never set in > TurbineLocalizationService, only in > JetspeedLocalizationService). > > The whole of the JetspeedLocalizationService class > can be reduced to a > single function, getLocale(RunData runData). > > The attached patch does this, and seems to work. > Yes, I compiled from > clean this time. :-) > > Jon > > > > > > -- > > Merlin Information Systems Limited, > > Merlin House, Gawcott Road, Buckingham, United > Kingdom. MK18 1TN > > Tel: +44 (0) 1280 824331 Fax: +44 (0) 1280 824112 > > > > http://www.misgl.com > > Provider of IT Services and Online Portal Support > Services. > > > > Confidentiality: > > The information contained in this email (including > any attachments) is confidential and is intended > solely for the use of the named addressee. Access, > copying or re-use of the information in it by any > other person is not authorised. If you are not the > intended recipient, please notify us immediately by > telephone or by e-mail to [EMAIL PROTECTED] > > > > > > *** This mail has been scanned for viruses *** > > > > > Index: > src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java > === > RCS file: >
Re: [patch] JetspeedLocalizationService
Hi David, David Sean Taylor wrote: The patch isn't necessary I just committed a patch from Missimilliano Dessi. It works fine as is. Although I thought we had country flag icons with the original portlet. I have just got round to using the latest CVS. I like the fact that the changeLanguage portlet is now a .vm, it will make it a lot easier to change the look and feel for my site. I'm still concerned though with org.apache.jetspeed.services.customlocalization.JetspeedLocalizationService. It still doesn't seem to work if you have more than one bundle defined in locale.default.bundles. It only seems to look at the first bundle. If you look at the class, it extends TurbineLocalizationService. JetspeedLocalizationService implements an initBundleNames() method which populates an instance variable String[] bundleNames. But all of the getString(...) methods call super.getString(...), where TurbineLocalizationService will use its own instance variables and will not find the strings. Let me put it another way. Each class defines an identical set of instance variables, like this: JetspeedLocalizationService TurbineLocalizationService === === private Hashtable bundles; private Hashtable bundles; private String bundleNames[]; private String bundleNames[]; private Locale defaultLocale; private Locale defaultLocale; private String defaultLanguage; private String defaultLanguage; private String defaultCountry; private String defaultCountry; After JetspeedLocalizationService.init() is called they look like this: JetspeedLocalizationService TurbineLocalizationService === == bundles null bundles set bundleNames[]setbundleNames[] null defaultLocalenull defaultLocale set defaultLanguage null defaultLanguage set defaultCountry null defaultCountry set when getString(String bundleName, Locale locale, String key) is called in JetspeedLocalizationService, it calls super.getString(...). This calls getBundle(String, Locale), which is implemented in JetspeedLocalizationService as a call to super.getBundle(String, Locale), so we are back to the code in TurbineLocalizationService. getBundle(String, Locale) in TurbineLocalizationService returns the default bundle to the getString(...) method. Back in getString(String bundleName, Locale locale, String key), we look up the requested key in the bundle, using getStringOrNull(), which returns null because the string I'm looking for isn't in the first bundle, it's in the second. The next test is intended to determine whether we need to check the other bundles for the key. The test is: // Look for text in list of default bundles. if (value == null && bundleNames.length > 0) At this point we throw a NullPointerException because bundleNames is null (it was never set in TurbineLocalizationService, only in JetspeedLocalizationService). The whole of the JetspeedLocalizationService class can be reduced to a single function, getLocale(RunData runData). The attached patch does this, and seems to work. Yes, I compiled from clean this time. :-) Jon -- Merlin Information Systems Limited, Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN Tel: +44 (0) 1280 824331 Fax: +44 (0) 1280 824112 http://www.misgl.com Provider of IT Services and Online Portal Support Services. Confidentiality: The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the information in it by any other person is not authorised. If you are not the intended recipient, please notify us immediately by telephone or by e-mail to [EMAIL PROTECTED] *** This mail has been scanned for viruses *** Index: src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java === RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java,v retrieving revision 1.4 diff -u -r1.4 JetspeedLocalizationService.java --- src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 26 Feb 2003 17:46:34 - 1.4 +++ src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 4 Mar 2003 12:49:37 - @@ -62,14 +62,10 @@ */ // Java imports -import java.util.Hashtable; import java.util.Locale; -import java.util.ResourceBundle; // Turbine imports import org.apache.turbine.services.localization.TurbineLocalizationService; -import org.apache.turbine.services.InitializationException; -import org.apache.turbine.services.resources.TurbineResources; import org.apache.turbine.util.RunData; // Jetspeed imports @@ -78,81 +74,6 @@ public class JetspeedLocali
Re: [patch] JetspeedLocalizationService
On Wednesday, February 26, 2003, at 04:17 AM, Jon Evans wrote: Jon Evans wrote: It's a bit of a dumb patch because all it does is to cut & paste a whole lot more code from turbine's TurbineLocalizationService. Because of this it was no longer worth extending TurbineLocalizationService, I extended TurbineBaseService instead. It turns out that the patch I attached doesn't work, it compiled as I wrote it but I think it only worked because I was doing an incremental compile, a clean compile failed. I have a new patch which adds a few missing methods which were needed to implement the interface. The new patch compiles fine. Rather than attach it again I'll wait to see what response I get from my previous message. If anyone wants the updated patch just let me know. Jon The patch isn't necessary I just committed a patch from Missimilliano Dessi. It works fine as is. Although I thought we had country flag icons with the original portlet. -- David Sean Taylor Bluesunrise Software [EMAIL PROTECTED] +01 707 773-4646 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [patch] JetspeedLocalizationService
Jon Evans wrote: (...) I also went through too much pain trying to find this feature in the first place. What is the best way to submit documentation changes? Check out the website CVS and submit a patch? Yes. The doc system uses the xdoc directory (don't edit the .html files, those are automatically generated). As an alternative, you could try to put you input under the Wiki http://nagoya.apache.org/wiki/ and put a link here. I think this could be a simpler way to start writing a document, specially if it requires feed back or additions from other people. Regards, Santiago Jon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [patch] JetspeedLocalizationService
Jon Evans wrote: It's a bit of a dumb patch because all it does is to cut & paste a whole lot more code from turbine's TurbineLocalizationService. Because of this it was no longer worth extending TurbineLocalizationService, I extended TurbineBaseService instead. It turns out that the patch I attached doesn't work, it compiled as I wrote it but I think it only worked because I was doing an incremental compile, a clean compile failed. I have a new patch which adds a few missing methods which were needed to implement the interface. The new patch compiles fine. Rather than attach it again I'll wait to see what response I get from my previous message. If anyone wants the updated patch just let me know. Jon -- Merlin Information Systems Limited, Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN Tel: +44 (0) 1280 824331 Fax: +44 (0) 1280 824112 http://www.misgl.com Provider of IT Services and Online Portal Support Services. Confidentiality: The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the information in it by any other person is not authorised. If you are not the intended recipient, please notify us immediately by telephone or by e-mail to [EMAIL PROTECTED] *** This mail has been scanned for viruses *** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[patch] JetspeedLocalizationService
Hi, I'm creating a portal application with Jetspeed and I needed to be able to change the language on the fly. I found JetspeedLocalizationService but it only worked when there was only one resource bundle was present. I needed a custom bundle plus the standard one. The problem was the way it delegated methods to the superclass, which would then look for strings in its uninitialized collections. With the attached patch I can now use $i10n.KEY, where KEY comes either from my own properties files or the stock Jetspeed files, and it all works fine. It's a bit of a dumb patch because all it does is to cut & paste a whole lot more code from turbine's TurbineLocalizationService. Because of this it was no longer worth extending TurbineLocalizationService, I extended TurbineBaseService instead. A more elegant solution would be to split out parts of TurbineLocalizationService into an abstract class and extend that instead, if necessary I can do that. What do you think? Would the Turbine folks be happy to take such a patch? I also went through too much pain trying to find this feature in the first place. What is the best way to submit documentation changes? Check out the website CVS and submit a patch? Jon -- Merlin Information Systems Limited, Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN Tel: +44 (0) 1280 824331 Fax: +44 (0) 1280 824112 http://www.misgl.com Provider of IT Services and Online Portal Support Services. Confidentiality: The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the information in it by any other person is not authorised. If you are not the intended recipient, please notify us immediately by telephone or by e-mail to [EMAIL PROTECTED] *** This mail has been scanned for viruses *** Index: src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationService.java === RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationService.java,v retrieving revision 1.1 diff -u -r1.1 CustomLocalizationService.java --- src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationService.java 14 Nov 2002 20:30:24 - 1.1 +++ src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationService.java 26 Feb 2003 11:05:12 - @@ -64,9 +64,10 @@ import java.util.ResourceBundle; import javax.servlet.http.HttpServletRequest; import org.apache.turbine.services.Service; +import org.apache.turbine.services.localization.LocalizationService; import org.apache.turbine.util.RunData; -public interface CustomLocalizationService extends Service +public interface CustomLocalizationService extends LocalizationService { public abstract String getDefaultBundleName(); @@ -79,5 +80,5 @@ public abstract String getString(String s, Locale locale, String s1); public static final String SERVICE_NAME = "LocalizationService"; -public static final String ACCEPT_LANGUAGE = "accept-Language"; +public static final String ACCEPT_LANGUAGE = "Accept-Language"; } Index: src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationTool.java === RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationTool.java,v retrieving revision 1.1 diff -u -r1.1 CustomLocalizationTool.java --- src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationTool.java 14 Nov 2002 20:30:24 - 1.1 +++ src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationTool.java 26 Feb 2003 11:05:12 - @@ -79,8 +79,7 @@ { try { -String s = CustomLocalization.getString(getBundleName(null), getLocale(), key); -return s; +return CustomLocalization.getString(getBundleName(null), getLocale(), key); } catch(MissingResourceException noKey) { Index: src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java === RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java,v retrieving revision 1.3 diff -u -r1.3 JetspeedLocalizationService.java --- src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 16 Nov 2002 17:30:31 - 1.3 +++ src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java 26 Feb 2003 11:05:12 - @@ -64,28 +64,54 @@ // Java imports import java.util.Hashtable; import java.util.Locale; +import java.util.MissingResourceExcep