You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ChambreNoire <aw...@tentelemed.com> on 2016/06/30 16:38:59 UTC

Dynamic localisation

Hello,

I wonder if any of you have encountered a similar problem.

I'd like to be able to replace specific localised terms depending on the
context (according to a session variable with can change during the session
life).

So for instance, in certain contexts all occurrences of the word 'user'
within property bundles would be displayed as 'collaborator'.

I'd like to be able to do this in a configurable manner rather than having
to define multiple versions of my property bundles depending on this
context.

Any ideas?

Thanks

CN

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Dynamic localisation

Posted by ChambreNoire <aw...@tentelemed.com>.
I think I'll try rolling my own Localizer to do on the fly substitutions
although that NestedStringResourceLoader looks pretty useful!

My thanks to you both,

CN

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990p4675001.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Dynamic localisation

Posted by Sven Meier <sv...@meiers.net>.
+1 that's really useful!

Thanks
Sven


On 01.07.2016 19:35, Tobias Soloschenko wrote:
> Hi,
>
> I remember a ticket in which this was a requirement. Maybe we should consider to take this implementation to core:
>
> https://github.com/klopfdreh/wicket-components-playground/wiki/22.-NestedStringResourceLoader
>
> kind regards
>
> Tobias
>
>> Am 01.07.2016 um 17:22 schrieb Sven Meier <sv...@meiers.net>:
>>
>> Hi,
>>
>> alternatively you could role your own Localizer or IStringResourceLoader that does some fancy replacement.
>>
>> Have fun
>> Sven
>>
>>
>>> On 01.07.2016 08:50, ChambreNoire wrote:
>>> The thing is, I don't know in advance which words need to be dynamically
>>> changed.
>>>
>>> So for instance :
>>>
>>> "The user is not currently associated with a service"
>>>
>>> I could want to replace 'user', 'service' or even 'associated' depending on
>>> the context.
>>>
>>> I could always add context-specific property files with the overridden
>>> version :
>>>
>>> package_contextA.properties > The peasant is not current managed by a
>>> landowner
>>>
>>> I suppose these could be generated at build by parsing the base
>>> package.properties and generating context-specific property files where
>>> necessary (only if these contain words to be replaced).
>>>
>>> Seems a bit messy though...
>>>
>>> CN
>>>
>>> --
>>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990p4674992.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> 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: Dynamic localisation

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,

I remember a ticket in which this was a requirement. Maybe we should consider to take this implementation to core:

https://github.com/klopfdreh/wicket-components-playground/wiki/22.-NestedStringResourceLoader

kind regards

Tobias

> Am 01.07.2016 um 17:22 schrieb Sven Meier <sv...@meiers.net>:
> 
> Hi,
> 
> alternatively you could role your own Localizer or IStringResourceLoader that does some fancy replacement.
> 
> Have fun
> Sven
> 
> 
>> On 01.07.2016 08:50, ChambreNoire wrote:
>> The thing is, I don't know in advance which words need to be dynamically
>> changed.
>> 
>> So for instance :
>> 
>> "The user is not currently associated with a service"
>> 
>> I could want to replace 'user', 'service' or even 'associated' depending on
>> the context.
>> 
>> I could always add context-specific property files with the overridden
>> version :
>> 
>> package_contextA.properties > The peasant is not current managed by a
>> landowner
>> 
>> I suppose these could be generated at build by parsing the base
>> package.properties and generating context-specific property files where
>> necessary (only if these contain words to be replaced).
>> 
>> Seems a bit messy though...
>> 
>> CN
>> 
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990p4674992.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> 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: Dynamic localisation

Posted by Sven Meier <sv...@meiers.net>.
Hi,

alternatively you could role your own Localizer or IStringResourceLoader 
that does some fancy replacement.

Have fun
Sven


On 01.07.2016 08:50, ChambreNoire wrote:
> The thing is, I don't know in advance which words need to be dynamically
> changed.
>
> So for instance :
>
> "The user is not currently associated with a service"
>
> I could want to replace 'user', 'service' or even 'associated' depending on
> the context.
>
> I could always add context-specific property files with the overridden
> version :
>
> package_contextA.properties > The peasant is not current managed by a
> landowner
>
> I suppose these could be generated at build by parsing the base
> package.properties and generating context-specific property files where
> necessary (only if these contain words to be replaced).
>
> Seems a bit messy though...
>
> CN
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990p4674992.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: Dynamic localisation

Posted by ChambreNoire <aw...@tentelemed.com>.
The thing is, I don't know in advance which words need to be dynamically
changed.

So for instance :

"The user is not currently associated with a service"

I could want to replace 'user', 'service' or even 'associated' depending on
the context.

I could always add context-specific property files with the overridden
version :

package_contextA.properties > The peasant is not current managed by a
landowner

I suppose these could be generated at build by parsing the base
package.properties and generating context-specific property files where
necessary (only if these contain words to be replaced).

Seems a bit messy though...

CN

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990p4674992.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Dynamic localisation

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You can use StringResourceModel for this. Check its javadoc.


Or org.apache.wicket.Component#getString(java.lang.String,
org.apache.wicket.model.IModel<?>):
Here is an example that I've seen recently:

Label selectedItemsCount = new Label("selectedItemsCount", new
Model<String>() {
            @Override
            public String getObject() {
                return getString("selected.items.count", new
Model<Serializable>(new Serializable() {
                    public int getCount() {
                        return getSelectedItems().size();
                    }
                }));
            }
        });

In MyApp.properties :
selected.items.count=${count} items


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Jun 30, 2016 at 6:38 PM, ChambreNoire <aw...@tentelemed.com> wrote:

> Hello,
>
> I wonder if any of you have encountered a similar problem.
>
> I'd like to be able to replace specific localised terms depending on the
> context (according to a session variable with can change during the session
> life).
>
> So for instance, in certain contexts all occurrences of the word 'user'
> within property bundles would be displayed as 'collaborator'.
>
> I'd like to be able to do this in a configurable manner rather than having
> to define multiple versions of my property bundles depending on this
> context.
>
> Any ideas?
>
> Thanks
>
> CN
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Dynamic-localisation-tp4674990.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>