-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all!
Anyone known how to load the content of i3-label.properties (and variants, eg en_US, IT, DE etc..) from a database?
I need to load the language from database, not from file.
Regards,
Agharta
There are two solutions, first is to implement your own LabelLocator, second is implement whole I18N Utilities yourself.
1.)implement your own LabelLocator
implements interface org.zkoss.util.resource.LabelLocator.
there's only one method you should implement that is public URL locate(Locale locale) throws Exception;
the url.openStream() should return a content which format is same as ZK i3-label format.
you can implement a Servlet to access DB, and form the URL to connect to that servlet.
But there is a limitation in this mechanism, that is ZK's I18N Label Handling model is static and in-memory, which means you can't change the label after initialization.
So if you want a model that you can change the label at runtime, you need to impl one for yourself.
2.)The I18N implementation in ZK is just a utility, you can implement one for yourself.
to see how to custom a I18N label resolving mechanism yourself, you can take a look at the src of:
org.zkoss.util.resource.impl.LabelLoader
org.zkoss.util.resource.Labels
Copy them as a base, declare your own tld for EL method.
It won't be too hard.
also you can post a feature request to SF.net, but you need to wait.
Asked: 2009-10-27 03:10:52 +0800
Seen: 624 times
Last updated: Oct 28 '09