|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
internationalization of exception messages in a database driver extensionHi All,
I'm looking for a possiblity to provide the user with custom exception messages in a database driver extension, according to the locale of his installation/system. The prefered solution from my side would be to provide the messages strtings in some sort of plain text ressource file(s) and fetch them from there in the driver. I have tried to find some modules with services covering that task in the OOo API, but get stuck with this, because all I found seems to be depricated or not suitable for this task (com.sun.star.i18n, com.sun.star.resource.XResourceBundle). How do you localize your extensions? Can anybody help me to solve this? Thanks, Micha |
|
|
Re: internationalization of exception messages in a database driver extensionHi Michael,
> I'm looking for a possiblity to provide the user with custom > exception messages in a database driver extension, according to the > locale of his installation/system. The prefered solution from my side > would be to provide the messages strtings in some sort of plain text > ressource file(s) and fetch them from there in the driver. I know that css.resource.OfficeResourceBundle is working fine (we use it in our drivers, too), but its drawback is that it's based on .res files, compiled from .src files when building OOo. Since I assume that your driver is not built in an OOo build env, but with the ODK, this is probably no option. I also know that the dialog localization feature is based on text files, but I'm somewhat lost on the details. AFAIK, the css.resource services can be used to access such files, but that's an educated guess only. I suggest you play a little with the StringResourceWithLocation service. The documentation of those services/interfaces seems to be ... above average :), so http://api.openoffice.org/docs/common/ref/com/sun/star/resource/StringResourceWithLocation.html might indeed help you. Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: internationalization of exception messages in a database driver extensionHi Michael,
> I'm looking for a possiblity to provide the user with custom > exception messages in a database driver extension, according to the > locale of his installation/system. As a completely unrelated side note, I am really happy to see somebody share my opinion that exception messages (i.e. css.uno.Exception.Message) are intended to be displayed to the end user, which implies they need to be a) Joe-Average-compatible (if possible at all) and b) localized. Have had a lot of discussions with others about this, but so far couldn't really convince anybody of this point of view :), which sadly results in Base, in 3.2, sometimes displaying something like "/some/path/to/source/file.cxx:1234" messages, since some low-level components decided that it's a good idea to transport this kind of information in Exception.Message :( Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
AW: internationalization of exception messages in a database driver extensionHi Frank,
Thanks for your answer. The StringResourceWithLocation service is exactly what I was looking for. I also found some helpful example code under http://markmail.org/message/sv2z4cvsgmgyctht, but it does not work yet because I do need a Component Context which I do not have (the drivers main class has a constructor with a parameter for the Component Context, but the constructor is called with null for this parameter) and I could not bootstrap for some reason (I get an exception that the OOo executable could not be found). Any ideas what I could do? My code looks like this (essentially the same as shown under http://markmail.org/message/sv2z4cvsgmgyctht): XPackageInformationProvider xPkgInfo = PackageInformationProvider.get(m_xContext); String resUrl = xPkgInfo.getPackageLocation("com.ingres.sdbcx") + "/resources/"; XStringResourceWithLocation xResources = StringResourceWithLocation.create(m_xContext, resUrl, true, new Locale("en", "US", ""), "Messages", "", null); String resString1 = xResources.resolveString("exMessage1"); Best Regards, Micha -----Ursprüngliche Nachricht----- Von: Frank Schoenheit, Sun Microsystems Germany [mailto:Frank.Schoenheit@...] Gesendet: Mi 23.09.2009 20:41 An: dev@... Betreff: Re: [dba-dev] internationalization of exception messages in a database driver extension Hi Michael, > I'm looking for a possiblity to provide the user with custom > exception messages in a database driver extension, according to the > locale of his installation/system. The prefered solution from my side > would be to provide the messages strtings in some sort of plain text > ressource file(s) and fetch them from there in the driver. I know that css.resource.OfficeResourceBundle is working fine (we use it in our drivers, too), but its drawback is that it's based on .res files, compiled from .src files when building OOo. Since I assume that your driver is not built in an OOo build env, but with the ODK, this is probably no option. I also know that the dialog localization feature is based on text files, but I'm somewhat lost on the details. AFAIK, the css.resource services can be used to access such files, but that's an educated guess only. I suggest you play a little with the StringResourceWithLocation service. The documentation of those services/interfaces seems to be ... above average :), so http://api.openoffice.org/docs/common/ref/com/sun/star/resource/StringResourceWithLocation.html might indeed help you. Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: AW: internationalization of exception messages in a database driver extensionHi Michaelm
> Thanks for your answer. The StringResourceWithLocation service is > exactly what I was looking for. I also found some helpful example > code under http://markmail.org/message/sv2z4cvsgmgyctht, but it does > not work yet because I do need a Component Context which I do not > have (the drivers main class has a constructor with a parameter for > the Component Context, but the constructor is called with null for > this parameter) and I could not bootstrap for some reason bootstrapping is no good idea, anyway, you'd have two of them in the same process then, if it would work at all. The driver's ctor is not the top-level entry point into your component, but a C function "component_getFactory" is. This creates a XSingleServiceFactory which is invoked when an instance of your driver is requested. Depending on how you implemented this function (basically: which helpers you used), this invocation is delegated to somewhere else. Usually, this is either a static method at your driver, or some global function. (naming conventions suggest something like Driver::Create or Driver_CreateInsrance.) Both of those usually take a XMultiServiceFactory parameter. If you're inside an OOo build environment, you have access to comphelper::ComponentContext, which you can create using the MSF. Otherwise, query the MSF for the XPropertySet interface, and retrieve the "DefaultContext" property. This way, you get an XComponentContext instance which you should use all across your driver implementation. Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
AW: AW: internationalization of exception messages in a database driver extensionHi Frank,
I'm a bit confused. Actually our driver extension is written in Java, but I guess getting the XComponentContext should be the same as if it were written in C and most of the code for providing the entry point to it was generated by NetBeans, so I didn't have to care much about it. I can see a method __getComponentFactory, which returns a XSingleComponentFactory, but all it takes is a string sImplementationName, no XMultiServiceFactory parameter. There seem to be two ways of providing the entry point for a component, the one implementing __getComponentFactory and another one implementing __getServiceFactory, which would take a XMultiServiceFactory and a XRegistryKey parameter in addition to sImplementationName. I must admit that I didn't really understand the difference between the two concepts, only that the __getComponentFactory way is the newer one and should be used for some reason. Do we need to change things to __getServiceFactory anyway or is there another solution? Best, Micha -----Ursprüngliche Nachricht----- Von: Frank Schoenheit, Sun Microsystems Germany [mailto:Frank.Schoenheit@...] Gesendet: Mo 28.09.2009 09:17 An: dev@... Betreff: Re: AW: [dba-dev] internationalization of exception messages in a database driver extension Hi Michaelm > Thanks for your answer. The StringResourceWithLocation service is > exactly what I was looking for. I also found some helpful example > code under http://markmail.org/message/sv2z4cvsgmgyctht, but it does > not work yet because I do need a Component Context which I do not > have (the drivers main class has a constructor with a parameter for > the Component Context, but the constructor is called with null for > this parameter) and I could not bootstrap for some reason bootstrapping is no good idea, anyway, you'd have two of them in the same process then, if it would work at all. The driver's ctor is not the top-level entry point into your component, but a C function "component_getFactory" is. This creates a XSingleServiceFactory which is invoked when an instance of your driver is requested. Depending on how you implemented this function (basically: which helpers you used), this invocation is delegated to somewhere else. Usually, this is either a static method at your driver, or some global function. (naming conventions suggest something like Driver::Create or Driver_CreateInsrance.) Both of those usually take a XMultiServiceFactory parameter. If you're inside an OOo build environment, you have access to comphelper::ComponentContext, which you can create using the MSF. Otherwise, query the MSF for the XPropertySet interface, and retrieve the "DefaultContext" property. This way, you get an XComponentContext instance which you should use all across your driver implementation. Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: AW: AW: internationalization of exception messages in a database driver extensionHello Michael,
On Tuesday 29 September 2009, 23:56, Michael Strobel wrote: > Hi Frank, > > I'm a bit confused. Actually our driver extension is written in Java, but I > guess getting the XComponentContext should be the same as if it were > written in C and most of the code for providing the entry point to it was > generated by NetBeans, so I didn't have to care much about it. then simply add a constructor that takes a css.uno.XComponentContext. public final class MyObjectFactory extends WeakBase { private final XComponentContext m_xContext; public MyObjectFactory(XComponentContext context) { m_xContext = context; } } Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: AW: AW: internationalization of exception messages in a database driver extensionHi Michael,
> I'm a bit confused. Actually our driver extension is written in Java, Ah - actually I don't know much (put carefully) about implementing UNO components in Java, so I hope that Ariel's idea solves your problem (I suppose it does, given Ariel's expertise :) ). So, assuming it does, some general remarks only: XSingleServiceFactory can be considered the legacy version of XSingleComponentFactory (and the same holds for the XMulti- versions). So, in general you should use the Component-version, and only fall back to the Service-thing if you interface with code which still needs it. In my understanding (and it's well possible that other major differences slip my attention), the most important advantage of the Component-API is that you have the XComponentContext, which can provide, well, context for your component, which reliefs implementations from accessing all kind of global shared data (which is a paint in the neck). Ciao Frank -- - Frank Schönheit, Software Engineer frank.schoenheit@... - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
AW: AW: AW: internationalization of exception messages in a database driver extensionHi Ariel and Frank,
@Frank: Again, thanks for your help and your explanations. @Ariel: >> public final class MyObjectFactory extends WeakBase { >> >> private final XComponentContext m_xContext; >> >> public MyObjectFactory(XComponentContext context) { >> m_xContext = context; >> } >> } Just to be sure, by css.uno.XComponentContext, you mean com.sun.star.uno.XComponentContext, right? Then this exactly what I have here for the driver class, but when the constructor is called the context that is passed is always null. I have no idea why we don't get a valid context here. As far as I understand is should be passed to the constructor, when createInstanceWithContext(XComponentContext context) of the XComponentSingleFactory for the driver class, which is returned by __getComponentFactory, is called from OOo side. There is also a class named CentralRegistrationClass (generated by NetBeans) that seems to get all the __getComponentFactory and __getComponentFactory calls from OOo side and then delegates them to the __getComponentFactory and __getComponentFactory methods of actual implementation classes. This class only has a private constructor that takes no parameters, but this is probably okay. Best, Micha --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: AW: AW: AW: internationalization of exception messages in a database driver extensionHello Michael,
On Wednesday 30 September 2009, 10:43, Michael Strobel wrote: > Hi Ariel and Frank, > > @Frank: Again, thanks for your help and your explanations. > > @Ariel: > >> public final class MyObjectFactory extends WeakBase { > >> > >> private final XComponentContext m_xContext; > >> > >> public MyObjectFactory(XComponentContext context) { > >> m_xContext = context; > >> } > >> } > > Just to be sure, by css.uno.XComponentContext, you mean > com.sun.star.uno.XComponentContext, right? yes, css is a shortcut for lazy people like me not wanting to type com.sun.star (it has no sense in Java, but the common use comes from C++, where you can shorten a namespace) > Then this exactly what I have > here for the driver class, but when the constructor is called the context > that is passed is always null. then this is quite strange. Java UNO component are quite easy and straight forward to develop (even more with the NB OOo plug-in). I assume everything is fine in OOo Base/Java UNO framework side. May be something is wrong somewhere in your code (or something is horribly broken in OOo side)... hard to guess without seeing your code. > I have no idea why we don't get a valid > context here. As far as I understand is should be passed to the > constructor, when createInstanceWithContext(XComponentContext context) of > the XComponentSingleFactory for the driver class, which is returned by > __getComponentFactory, is called from OOo side. If you are using the factory helper from the javaunohelper, then all you have simply have to do is write the proper constructor, see http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Create_Instance_with_Arguments "Alternatively, a component may also receive these arguments in its constructor. ... When using the FactoryHelper, implement the constructors with the following arguments: [see table] The FactoryHelper *automatically* passes the array of arguments it received from the createInstanceWithArguments[AndContext]() call to the appropriate constructor." As you see, this should be rather straight forward. > There is also a class named CentralRegistrationClass (generated by > NetBeans) that seems to get all the __getComponentFactory and > __getComponentFactory calls from OOo side and then delegates them to the > __getComponentFactory and __getComponentFactory methods of actual > implementation classes. This class only has a private constructor that > takes no parameters, but this is probably okay. yes, this is a helper class, useful when you have several UNO components in a same JAR file; in the nbproject/project-uno.properties you will have the central registration class, the entry point for all components in your JAR: central.registration.class=<org.openoffice.examples>.CentralRegistrationClass All UNO components classes are listed, separated by a space in registration.classname=<org.openoffice.examples.>MyObjectFactory1 <org.openoffice.examples.>MyObjectFactory2 <org.openoffice.examples.>MyObjectFactory3 As you can have several UNO component per JAR file, you could try adding another, but dummy, component, using the same CentralRegistrationClass and the com.sun.star.lib.uno.helper.Factory helper, and then debug to see if the constructor with the XComponentContext works with it. Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
AW: AW: AW: AW: internationalization of exception messages in a database driver extensionHi Ariel,
> I assume everything is fine in OOo Base/Java UNO framework side. > May be something is wrong somewhere in your code (or something is horribly > broken in OOo side)... hard to guess without seeing your code. Since nobody experienced this problem with the XComponentContext before I guess it is related to my code ;) If you like to, you can browse/checkout the code from our subversion repository under http://code.ingres.com/apps/openoffice/trunk. > yes, this is a helper class, useful when you have several UNO components in a > same JAR file; in the nbproject/project-uno.properties you will have the > central registration class, the entry point for all components in your JAR: > central.registration.class=<org.openoffice.examples>.CentralRegistrationClass > All UNO components classes are listed, separated by a space in > registration.classname=<org.openoffice.examples.>MyObjectFactory1 > <org.openoffice.examples.>MyObjectFactory2 > <org.openoffice.examples.>MyObjectFactory3 I have fixed a misspelling in the properties and added some __getComponentFactory and __writeRegistryServiceInfo methods for the components listed there, but this did not fix the problem with the XComponentContext. I guess these things regarded another potential issue, because the methods were only missing in classes that are instantiated within my code by calling the classes constructors directly, which seems to work fine. The changes that I made are not yet in our repository. Best, Micha --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |