Hi,

I'd like to use some localized strings within a model class.

Can I use any of Wicket's localization capabilities for this?
Localizer assumes you have a component reference to pass to the various getString (...) call, but I don't have access to one.


Here is an example below (sorry if it's not clear, it's Scala syntax):

--
class FileSizeModel (model: IModel[Long]) extends Model[String] {
        val KB = 1024
        val MB = KB * 1024
        val GB = MB * 1024

        override def getObject: String = {
                val size = model.getObject
                var label: String = ""
                if (size > GB) label = "%dG" format (size / GB)
                else if (size > MB) label = "%dM" format (size / MB)
                else if (size > KB) label = "%dk" format (size / KB)
                else label = "%d  bytes" format (size)
                label
        }
}
--

I would like to have a corresponding FileSizeModel.properties to set the various labels (G, M, k, bytes)


I know I can inject a Spring message source, etc., but unsure if I can leverage Wicket's localization for this.

Thanks

P.S. leave me alone about GB vs. GiB differences in the example, etc. ;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to