• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Localized EO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Localized EO


  • Subject: Re: Localized EO
  • From: "Daniele Corti" <email@hidden>
  • Date: Thu, 12 Jul 2007 17:47:17 +0200

Hi Johann,
   look, I think you are make it too complicated... It would be easy if you create some localizable files (e.g. Italian.lproj/Localizable.strings, English.lproj/Localizable.strings, etc) than make for them the same key:

//English Localizable.strings
{
haveANiceDayPrompt = "Hava a nice day!!!!";
}
//Italian Localizable.strings
{
haveANiceDayPrompt = "Ti auguro una buona giornata!!!";
}

then you shuold save in your eo the key corresponding (e.g. EO.prompt)

in the end call, ERXLocalizer.defaultLocalizer().localizeString(yourEO.prompt());

Then you'll have the string localized by the language defined in er.extensions.ERXLocalizer.defaultLanguage system property.

You can define it by System.setProperty("er.extensions.ERXLocalizer.defaultLanguage")  = "Italian"; or "English"

-----------------

A completly different approach is to save the localized strings in the db:

your EOs should be:

Salutation <---->  LocalizedAttribute
LocalizedAttribute <---------->> LocalizedString
LocalizedString <<------------> Language

then in the Salutation class define a localize method:

public LocalizedString localize(String language, EOEditingContext ec)
{
     Long l = this.idSalutation (); //The Primary Key of the table
     EOKeyValueQualifier qual = new EOKeyValueQualifier("localizedAttribute.salutation.idSalutation", EOQualifier.QualifierOperatorEqual, l);
     EOKeyValueQualifier qual1 = new EOKeyValueQualifier(" language.langName", EOQualifier.QualifierOperatorCaseInsensitiveLike, language);
     NSArray myArr = new NSArray(new Object[]{qual, qual1});
     EOFetchSpecification fetchSpecification = new EOFetchSpecification("LocalizedString", new EOAndQualifier(myArr), null);
     fetchSpecification.setRefreshesRefetchedObjects(true);
     NSArray ret = ec.objectsWithFetchSpecification(fetchSpecification);
     return (ret != null) ? (LocalizedString)ret.lastObject() : null;
}

I hope it is clear...
Bye

2007/7/12, Johann Werner <email@hidden>:
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: email@hidden




--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden

--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS

--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young
 _______________________________________________
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>)

  • Prev by Date: Re: EOAndQualifier order
  • Next by Date: Re: AjaxUpdateContainer encoding issue
  • Previous by thread: Localized EO
  • Next by thread: Re: Localized EO
  • Index(es):
    • Date
    • Thread