You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by 7zark7 <7z...@gmail.com> on 2010/10/30 08:47:26 UTC

get localized string from Model class?

Hi,

I am writing a IModel<String> implementation which formats Dates in a 
particular way.

I would like the text to be in localized properties files, however I 
can't seem to leverage anything in Wicket for this.  Localizer expects a 
component to be passed to its getString methods, which I do not have a 
reference to.

Anyone have ideas or done similar?


Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get localized string from Model class?

Posted by James Carman <ja...@carmanconsulting.com>.
On Sat, Oct 30, 2010 at 2:47 AM, 7zark7 <7z...@gmail.com> wrote:
> I am writing a IModel<String> implementation which formats Dates in a
> particular way.
>
> I would like the text to be in localized properties files, however I can't
> seem to leverage anything in Wicket for this.  Localizer expects a component
> to be passed to its getString methods, which I do not have a reference to.
>
> Anyone have ideas or done similar?
>

Why not have your model implementation that takes an IModel<String>
that returns the format string?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get localized string from Model class?

Posted by 7zark7 <7z...@gmail.com>.
I understand that, but in this case a IModel or IConverter seems 
appropriate since I'm only interested in the string representation of a 
date, not page or component markup.

However, in doing this, you seem to lose some of Wicket's nice 
localization conventions.


On 10/30/10 11:36 PM, vineet semwal wrote:
> afaik you should only have property files corresponding to your components
> ,pages or application.
> however if you just want to do your own way you can always use get your
> resourcebundle.
>
> On Sun, Oct 31, 2010 at 11:51 AM, 7zark7<7z...@gmail.com>  wrote:
>
>> Hmm, that didn't seem to find a property if I have the property file
>> specific to the model class, e.g.:
>> NiceDateModel.properties
>>
>> However, I see now there's some classes such as:
>>
>> IComponentAssignedModel<java.lang.String>
>>
>> or perhaps I should subclass StringResourceModel, etc.
>>
>> Will look into it further,
>>
>> Thanks
>>
>>
>>
>> On 10/30/10 4:53 AM, 7zark7 wrote:
>>
>>> Thank you, I'll give that try!
>>>
>>> On Oct 30, 2010, at 1:51 AM, "Bas Gooren"<ba...@iswd.nl>   wrote:
>>>
>>>   The component parameter can be null.
>>>>
>>>> e.g. if you look at getObject() in the ResourceModel class:
>>>>
>>>> return
>>>> Application.get().getResourceSettings().getLocalizer().getString(resourceKey,(Component<String>)null,
>>>> defaultValue);
>>>>
>>>> It calls Localizer#getString with the resource key and optionally a
>>>> component.
>>>>
>>>> Sebastian
>>>>
>>>> ----- Original Message ----- From: "7zark7"<7z...@gmail.com>
>>>> To: "Wicket"<us...@wicket.apache.org>
>>>> Sent: Saturday, October 30, 2010 8:47 AM
>>>> Subject: get localized string from Model class?
>>>>
>>>>
>>>>   Hi,
>>>>>
>>>>> I am writing a IModel<String>   implementation which formats Dates in a
>>>>> particular way.
>>>>>
>>>>> I would like the text to be in localized properties files, however I
>>>>> can't seem to leverage anything in Wicket for this.  Localizer expects a
>>>>> component to be passed to its getString methods, which I do not have a
>>>>> reference to.
>>>>>
>>>>> Anyone have ideas or done similar?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get localized string from Model class?

Posted by vineet semwal <vi...@gmail.com>.
afaik you should only have property files corresponding to your components
,pages or application.
however if you just want to do your own way you can always use get your
resourcebundle.

On Sun, Oct 31, 2010 at 11:51 AM, 7zark7 <7z...@gmail.com> wrote:

> Hmm, that didn't seem to find a property if I have the property file
> specific to the model class, e.g.:
> NiceDateModel.properties
>
> However, I see now there's some classes such as:
>
> IComponentAssignedModel<java.lang.String>
>
> or perhaps I should subclass StringResourceModel, etc.
>
> Will look into it further,
>
> Thanks
>
>
>
> On 10/30/10 4:53 AM, 7zark7 wrote:
>
>> Thank you, I'll give that try!
>>
>> On Oct 30, 2010, at 1:51 AM, "Bas Gooren"<ba...@iswd.nl>  wrote:
>>
>>  The component parameter can be null.
>>>
>>> e.g. if you look at getObject() in the ResourceModel class:
>>>
>>> return
>>> Application.get().getResourceSettings().getLocalizer().getString(resourceKey,(Component<String>)null,
>>> defaultValue);
>>>
>>> It calls Localizer#getString with the resource key and optionally a
>>> component.
>>>
>>> Sebastian
>>>
>>> ----- Original Message ----- From: "7zark7"<7z...@gmail.com>
>>> To: "Wicket"<us...@wicket.apache.org>
>>> Sent: Saturday, October 30, 2010 8:47 AM
>>> Subject: get localized string from Model class?
>>>
>>>
>>>  Hi,
>>>>
>>>> I am writing a IModel<String>  implementation which formats Dates in a
>>>> particular way.
>>>>
>>>> I would like the text to be in localized properties files, however I
>>>> can't seem to leverage anything in Wicket for this.  Localizer expects a
>>>> component to be passed to its getString methods, which I do not have a
>>>> reference to.
>>>>
>>>> Anyone have ideas or done similar?
>>>>
>>>>
>>>> Thanks
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
regards,
Vineet Semwal

Re: get localized string from Model class?

Posted by 7zark7 <7z...@gmail.com>.
Hmm, that didn't seem to find a property if I have the property file 
specific to the model class, e.g.:
NiceDateModel.properties

However, I see now there's some classes such as:

IComponentAssignedModel<java.lang.String>

or perhaps I should subclass StringResourceModel, etc.

Will look into it further,

Thanks


On 10/30/10 4:53 AM, 7zark7 wrote:
> Thank you, I'll give that try!
>
> On Oct 30, 2010, at 1:51 AM, "Bas Gooren"<ba...@iswd.nl>  wrote:
>
>> The component parameter can be null.
>>
>> e.g. if you look at getObject() in the ResourceModel class:
>>
>> return Application.get().getResourceSettings().getLocalizer().getString(resourceKey,(Component<String>)null, defaultValue);
>>
>> It calls Localizer#getString with the resource key and optionally a component.
>>
>> Sebastian
>>
>> ----- Original Message ----- From: "7zark7"<7z...@gmail.com>
>> To: "Wicket"<us...@wicket.apache.org>
>> Sent: Saturday, October 30, 2010 8:47 AM
>> Subject: get localized string from Model class?
>>
>>
>>> Hi,
>>>
>>> I am writing a IModel<String>  implementation which formats Dates in a particular way.
>>>
>>> I would like the text to be in localized properties files, however I can't seem to leverage anything in Wicket for this.  Localizer expects a component to be passed to its getString methods, which I do not have a reference to.
>>>
>>> Anyone have ideas or done similar?
>>>
>>>
>>> Thanks
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get localized string from Model class?

Posted by 7zark7 <7z...@gmail.com>.
Thank you, I'll give that try!

On Oct 30, 2010, at 1:51 AM, "Bas Gooren" <ba...@iswd.nl> wrote:

> The component parameter can be null.
> 
> e.g. if you look at getObject() in the ResourceModel class:
> 
> return Application.get().getResourceSettings().getLocalizer().getString(resourceKey,(Component<String>)null, defaultValue);
> 
> It calls Localizer#getString with the resource key and optionally a component.
> 
> Sebastian
> 
> ----- Original Message ----- From: "7zark7" <7z...@gmail.com>
> To: "Wicket" <us...@wicket.apache.org>
> Sent: Saturday, October 30, 2010 8:47 AM
> Subject: get localized string from Model class?
> 
> 
>> Hi,
>> 
>> I am writing a IModel<String> implementation which formats Dates in a particular way.
>> 
>> I would like the text to be in localized properties files, however I can't seem to leverage anything in Wicket for this.  Localizer expects a component to be passed to its getString methods, which I do not have a reference to.
>> 
>> Anyone have ideas or done similar?
>> 
>> 
>> Thanks
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get localized string from Model class?

Posted by Bas Gooren <ba...@iswd.nl>.
The component parameter can be null.

e.g. if you look at getObject() in the ResourceModel class:

return 
Application.get().getResourceSettings().getLocalizer().getString(resourceKey,(Component<String>)null, 
defaultValue);

It calls Localizer#getString with the resource key and optionally a 
component.

Sebastian

----- Original Message ----- 
From: "7zark7" <7z...@gmail.com>
To: "Wicket" <us...@wicket.apache.org>
Sent: Saturday, October 30, 2010 8:47 AM
Subject: get localized string from Model class?


> Hi,
>
> I am writing a IModel<String> implementation which formats Dates in a 
> particular way.
>
> I would like the text to be in localized properties files, however I can't 
> seem to leverage anything in Wicket for this.  Localizer expects a 
> component to be passed to its getString methods, which I do not have a 
> reference to.
>
> Anyone have ideas or done similar?
>
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org