Re: Localized EO
Re: Localized EO
- Subject: Re: Localized EO
- From: Jean-François Veillette <email@hidden>
- Date: Thu, 12 Jul 2007 12:11:30 -0400
We have solved this problem by enhancing kvc at the component level.
Let's say you have those attributes : name_FR, name_EN, name_DU, etc.
which holds localized values for the name attribute.
what we do is we alter the keypath that ask for 'name'.
instead of wostring: value= myEO.name;
and let myEO return the correct name depending on the current context
(which is session dependent), we do :
wostring = @translateByAppendingSuffix.myEO.name
and we have the method translateByAppendingSuffix that receive one
argument, the rest of the keypath. this method will append the
current language prefix to the keypath and return valueForKeyPath
(newKeyPath).
I think (vaguely remembre) that I posted code already on this list
about that.
If you can't find it, let me know, I'll digg it for you.
- jfv
Le 07-07-12 à 11:08, Johann Werner a écrit :
Hi all,
sorry to bother the list but I am stuck.
in short: I want to make some EOs behave localized.
long story: In my project I have some fixed lists as e.g.
salutations that are saved in the db. There I want to use the
approach of the localizable.strings lookup (I am using ERXLocalizer
from WOnder). To make this process transparent I had the idea to
modify the accessors of the eo to look up the value in the db and
then based on the current language setting retrieve the correct
localized string from the .strings file. So I would call the
accessor as any other but get a result based on the used language.
For lists that are user editable I use another approach by
replacing the string in the entity by a to-many relationship
pointing to an eo with a localized string and a language code. So
in this case the eo should get the current language setting and
then choose the correct subentity from the to-many relationship and
return the appropriate localized string.
Unfortunately the language settings are accessed by session
().localizer() and there is apparently no way to access the current
session object from within an eo. I know I could pass the current
session (or only the code for the current language) through by an
argument but then I can't use bindings in components without
writing intermediate access functions resulting in more unnecessary
code and no transparent use of that eo would be possible.
As I am new to localization in WO I don't know if my ideas go
perhaps into the wrong direction. I would be very thankfull if
someone could give me a hint if the descibed approach is advisable
or if there is another (more elegant) way to resolve the problem.
jw
_______________________________________________
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
References: | |
| >Localized EO (From: Johann Werner <email@hidden>) |