Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: where to put a global dictionary  (Read 7715 times)
hesten
Sr. Member
****
Posts: 52


View Profile Email
« 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
hesten
Sr. Member
****
Posts: 52


View Profile Email
« Reply #2 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 :)
Logged
Pages: [1]
Print