Articles Archive
Articles Search
Director Wiki
 

Creating Multi-lingual Director Movies

August 14, 2001
by Will Turnage

Hey Multimedia Handyman,

I'm getting ready to develop a multi-lingual presentation in Director. A total of 7 languages will be used: Spanish, French, Italian, German, Portuguese, Japanese, and English.

Any advice?

cheers,

Lance Endres

Dear Lance,

If you've ever been faced with a project that needs to be delivered in more than one language, the last thing you want to do is to recreate the Director movie for each language you need. Aside from making two or three times more work for you to do, creating separate movies also increases the likeliness that a bug will exist in one movie and not another. Plus if you have to make last minute changes, then you have to go through and make the changes for each and every language.

However, if the general content and functionality of your program is the same across the different languages, then you don't have to make separate Director movies. The key is to use separate castLibs for each language's assets. Then, you can have one Score and one set of scripts for all of your languages, and you just use a different castLib based on which language you've selected.

Here's how you can switch casts content using either external castLibs or internal castLibs.

Switching external casts

The easiest way to switch between multiple languages is by using external casts. Say, for instance, that your movie has two casts in it. The first castLib is named Internal, and it contains all of your scripts and background elements. The second castLib is named Media and is linked to an external cast file named english.cst which contains all of your English-only assets. In addition, there are two other external castLibs sitting in the same folder as your movie. They are named espanol.cst and deutsch.cst. If you wanted to switch languages, then all you have to do is switch the fileName of your Media castlib.

castLib ("Media")Filename = "deutsch.cst"
castLib ("Media")Filename = "espanol.cst"

The key to making this work, though, is that all of the members in each castLib must be in the same order. So if you have 10 bitmaps in the first ten members of your English cast, you need to have corresponding bitmaps in the exact same positions in the casts for your other languages.

Switching internal casts

If for some reason you don't want to use external casts and would rather keep all of your casts internal to your movie, then you can do it this way as well, although it's slightly more complicated. In this instance, instead of having one cast and swapping out its filename, you will have all of your casts internal to your movie. To relate to the previous example, you would have four separate internal casts named Internal, English, Espanol, and Deutsch.

The next step is to have a global variable that keeps track of which language you're currently viewing.

global gLanguage

gLanguage = "english"
gLanguage = "espanol"

Next, you need to place a behavior on every single sprite in your movie that contains a language element. That behavior will contain this code:

global gLanguage

on beginSprite me
  me.setLanguageMember ()
end

on setLanguageMember me
  myNum = sprite (me.spriteNum).memberNum
  if member (myNum, gLanguage).type <> #empty then
    sprite (me.spriteNum).member = member (myNum, gLanguage)
  end if
end

When this behavior starts, it calls a handler called setLanguageMember. The first thing this handler does is determine the memberNum of the member that it's attached to. Next, it checks to make sure that a valid member exists in the new cast, and if so, then it switches the member to be the member in the new castLib. As with the external cast method, the key to making this work is to make sure that each cast is set up identically.

The reason that all of the code is kept in a separate handler is so you can call it whenever you change languages. So in your movie you could say

gLanguage = "deutsch"
sendAllSprites(#setLanguageMember)

and this would force all of the on-screen sprites to switch themselves to the appropriate language.

A sample Director 8 movie is available for download in Macintosh or Windows format.

Will Turnage is a multimedia programmer based in New York City. In addition to his weekly role as Director Online's Multimedia Handyman, he is also the Technology Director for Sony Music's Client Side Technologies Group. You can read more about his work at http://will.turnage.com/.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.