Multi-lingual movies are something Director handles very well. Many people approach this problem thinking that they will need a new Director movie for each language they build. The other approach people consider is to put redundant versions of everything in their internal cast and just have lingo load the correct graphics. This can work, but your files are loading far more data than they ever need to use, and it will unnecessarily slow you down. So what is the easiest way to do this? Well, as most Director users realize, Director can link to external files. This is handy when working on a project and you want to swap out the graphics. Just write over them and Director uses the new version. The same thing can be applied to cast libraries as well, and Director can even swap them out on the fly. For the sake of simplicity, lets take a few images to do our little test.
Lets make a simple movie with one image and a set of 5 buttons. The image will be of a flag and each button will distinguish a country/language. The buttons and scripts all go in the internal cast, but we place the graphic in an external cast named "language." One nice thing about Director's casts is that the cast library name does not need to be the same as the file that it uses. We save this external library as "english.cst." Now here comes the trick. We copy this cast and rename each copy to a different language. (French, German, Japanese, and Spanish) We then open each library and swap the graphic for one more suited to the current language. Make sure to keep the names and location the same as this is how lingo and Director can be referencing the members, but as far as the project knows it will still be using the same graphic. Now we open up the original movie that is still linked to the "english.cst" file. In it we place this script...
--Copyright 1999 Chuck Neal
--If you find this code helpful, send me an e-mail and let me know. :-)
if gLanguage = void then gLanguage = "english"
currentFilename = castlib("language").filename
if the platform contains "Win" then
theD = "\"
theD = ":"
the itemDelimiter = theD
thePath = currentFilename.item[1..(currentFilename.item.count - 1)]
castlib("Language").filename = thePath & theD & gLanguage
on getBehaviorDescription me
return "This script swaps out the castlib named language for another external library in the same directory that is named the same as the language it uses. For example, the file used by the language library might be named spanish.cst. When changing the global gLanguage to french then running the script, the language cast is swapped for the french.cst file."
Now all we need to do is have the buttons change the value for the global variable "gLanguage" and have them run this handler. The handler checks the current location of the castlib and looks for a cast with the name of the language. It then opens that library and everything in the score is referencing the new cast. This is pretty simple for one image, but imagine the time it saves with a project that has hundreds of assets. Sounds, text items, graphics and more can all be swapped with ease by just changing out the cast library. Give it a try and you will quickly see how this one little property of a cast library can be very powerful.
36 South Court Sq
Newnan, GA 30263