2.3. Checking the System Language


You want to know what language is used on the computer playing the movie.


Use the System.capabilities.language property.


You can use the System.capabilities.language property to determine the language of the computer that is playing the movie. The property returns a two-letter ISO-639-1 language code (i.e., “fr” for French). Where applicable, a two-letter country code is appended, separated from the language code with a hyphen (i.e., “en-US” for U.S. English and “en-UK” for U.K. English).

For a summary of language codes, see the following resources:


Here is an example of how to use the language property:

// Example output: en-US

You can use this property to dynamically load content in the appropriate language:

// Create an associative array with language codes 
// for the keys and greetings for the values.
greetings = new Array(  );
greetings["en"] = "Hello";
greetings["es"] = "Hola";
greetings["fr"] = "Bonjour";

// Extract the first two characters from the language code.
lang = System.capabilities.language.substr(0, 2);

// Use a default language if the language is not in the list.
if (greetings[lang] == undefined) {
  lang = "en";

// Display the greeting in the appropriate language.

When you want to offer multiple language capabilities ...

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.