Re: Reusable translated button
Re: Reusable translated button
- Subject: Re: Reusable translated button
- From: Chuck Hill <email@hidden>
- Date: Mon, 21 Aug 2006 10:03:24 -0700
On Aug 21, 2006, at 8:19 AM, Fabrice Pipart wrote:
Hi list !
I am trying to make a reusable component to have buttons translated.
The idea is to just provide a key to the button that will take care
to find the translation in the .strings
This looks like Chuck's "LocaleString" but for buttons.
Here is what I did :
TranslatedButton HTML :
<webobject name="link"><webobject name="button"></webobject></
webobject>
Having an input wrapped in a hyperlink sounds like a recipe for
headache.
TranslatedButton .wod :
button : WOGenericElement {
elementName = "input";
type = "button";
value = translatedKey;
}
link : WOHyperlink {
action = action;
}
And I call it using bindings like :
loginButton : TranslatedButton {
action = logIn;
key = "a_key";
}
And here is my problem :
How can I manage to have
- the key bound in TranslatedButton (to be able to translate the
key with a ApplicationUtilities.translate(key, session().languages
()) )
public String translatedKey() {
return ApplicationUtilities.translate(key(), session().languages
()) );
}
- have the logIn method called in the parent component
Things get a bit confusing there with your implementation.
I know I could use performParentAction() but it takes a String and
it would not allow me to use code completion in WOLips.
Is there something I can do?
Decide to use Plan B. KVC is your friend. Rather than a custom
component, how about just this:
webobject name="button"></webobject>
button: WOSubmitButton {
action = login;
value = @localize.a_key;
}
override valueForKeyPath in your WOComponent superclass to detect
@localize and pass the part after the "." to
ApplicationUtilities.translate(key, session().languages()) ). That
way to do it once, and you can easily localize the standard WO
components. See our WOExtensions framework for example code, or
just use that framework. :-)
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden