PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: hesten on July 23, 2009, 07:13:30



Title: where to put a global dictionary
Post by: hesten on July 23, 2009, 07:13:30
Hi All

I have a project where the various view components need to reference a global dictionary for common phrases (like "more info") - the site is versioned for more than one language.

The question is where to put this object.

My plan is to the have the method to retrieve a phrase as a public static method, so everybody can access it, and I was thinking I would keep it in my "contants" folder, and populate it from the proxy that loads all the globals for the site.

Does that make sense?

Regards


Title: Re: where to put a global dictionary
Post by: puremvc on July 25, 2009, 04:25:39
There are lots of ways to manage this sort of thing, and it really depends on the scope of your application, the strings that need to be internationalized, etc.

If it's one or two short phrases, you might put them in constants, sure. If it's a potentially endless number of phrases of any length, which may be loaded instead of baked into your app, you probably want a more sophisticated approach.

For the latter, I'd suggest having a Proxy that is in charge of knowing the current language and fetching the right strings. Since AS3 has XML as a native datatype, make a nice XML structure holding all the key value and have the Proxy load it (after startup preparation of view and model is complete) and send out a notification with it as the body. Then your Mediators can pass a reference to the structure to the view components which can bind to E4X expressions that pull the strings out.

-=Cliff>


Title: Re: where to put a global dictionary
Post by: hesten on July 27, 2009, 01:12:26
Hi Cliff

In this case there are only a handfull phrases. They are used for button labels like "more info", and stuff like that. Other than that translations are "pages" in a backend system and loaded as part of specific page data. The only reason for "globalising" some phrases are to make life a bit easier on the web admins.

Thank you for your input :)