Creating multilanguage text



You can configure a FLA file to display text in different languages depending on the language of the operating system that plays the Flash content.

Workflow for authoring multilanguage text with the Strings panel

The Strings panel lets you create and update multilingual content. You can specify content for text fields that span multiple languages, and have Flash automatically determine the content that should appear in a certain language based on the language of the computer running Flash Player.

The following steps describe the general workflow:

1. Author a FLA file in one language.

Any text to enter in another language must be in a dynamic or input text field.

2. In the Strings Panel Settings dialog box, select the languages to include and designate one of them as the default language.

A column for the language is added to the Strings panel. When you save, test, or publish the application, a folder with an XML file is created for each language.

3. In the Strings panel, encode each text string with an ID.

4. Publish the application.

A folder is created for each language you select, and within each language folder is an XML file for that language.

5. Send the published FLA file and XML folders and files to your translators.

Author in your native language and let the translators make the translation. They can use translation software directly in the XML files or in the FLA file.

6. When you receive the translations from your translators, import the translated XML files back into the FLA file.

Select and remove languages for translation

As many as 100 languages can appear on the Stage and in the Strings panel for translation. Each language you select becomes a column in the Strings panel. To show the text on the Stage in any of the languages you selected, change the Stage language. The selected language appears when you publish or test the file.

When selecting languages, use any of the languages provided in the menu, as well as any other Unicode-supported language.

Select a language

  1. Select Window > Other Panels > Strings, and click Settings.
  2. Add a language by doing one of the following:
    • In the Languages box, highlight a language to select, and click Add.

    • If the language does not appear in the Languages box, in the blank field below the Languages box, type a language code in the format xx. (The language code is from ISO 639‑1.) Click Add.

  3. Repeat step 3 until you have added all the necessary languages.
  4. Select a default language from the Default runtime language menu. This language appears on systems that do not have one of the active languages you selected.
  5. To load an XML file for the languages from a different URL at runtime, type the URL in the URL text field and click OK.

    A column for each selected language appears in the Strings panel. The columns appear in alphabetical order.

  6. Save the FLA file. When you save the FLA file, a folder for each language you selected is created in the same folder indicated in the SWF publish path. If no SWF publish path has been selected, it is created in the folder the FLA file resides in. Within each language file an XML file is created that is used to load translated text.

Remove a language

  1. Select Window > Other Panels > Strings, and click Settings.
  2. In the Active languages field, highlight a language and click Remove.
  3. Repeat step 3 until you have removed all the unwanted languages.
  4. When you finish removing languages, click OK.

    The column for each removed language no longer appears in the Strings panel.

Note: When you remove a language from the Strings panel, the language XML file is not deleted from the local file system. This lets you add the language back into the Strings panel by using the previous XML file, and prevents accidental deletion. To completely remove the language, you must delete or replace the language XML file.

Add strings to the Strings panel

Assign text strings to the Strings panel in the following ways:
  • Assign a string ID to a dynamic or input text field

  • Add a string to the Strings panel without assigning it to a text field

  • Assign an existing string ID to an existing dynamic or input text field

Assign a string ID to a text field

  1. Select Window > Other Panels > Strings.
  2. Select the Text tool. On the Stage, create an input or dynamic text field.
  3. While the text field is selected, type a unique ID in the ID field in the Strings panel.
  4. Click the Settings button and select a language or languages from the list in the Settings dialog box. The languages you select should include the default language you wish to use and any other languages in which you plan to publish your work.
  5. Click Apply.
Note: If a static text field is selected on the Stage, the Stage text selection section on the Strings panel displays the message “Static text cannot have an ID associated with it.” If a nontext item is selected or multiple items are selected, the message “Current selection cannot have an ID associated with it” appears.

Add a string ID to the Strings panel without assigning it to a text field

  1. Select Window > Other Panels > Strings.
  2. Click the Settings button and select a language or languages from the list in the Settings dialog box. The languages you select should include the default language you wish to use and any other languages in which you plan to publish your work.
  3. Type a new string ID and new string in the Strings panel, and click Apply.

Assign an existing ID to a text field

  1. Select the Text tool. On the Stage, create an input or dynamic text field.
  2. Type the name of an existing ID in the ID section of the Strings panel, and click Apply.
Note: Press Shift+Enter to apply the ID to the text field, or Enter if the focus is on the ID field.

Editing strings in the Strings panel

After you enter text strings in the Strings panel, use one of the following methods to edit the text strings:

  • Directly in the Strings panel cells.

  • On the Stage in the language selected as the Stage language, using features such as find and replace and spelling checking. Text that you change using these features is changed on the Stage and in the Strings panel.

  • Edit the XML file directly.

Change the language displayed on the Stage

  1. Select Window > Other Panels > Strings.
  2. In the Stage Language menu, select the language to use for the Stage language. This must be a language you added as an available language.

    After you change the Stage language, any new text you type on the Stage appears in that language. If you previously entered text strings for the language in the Strings panel, any text on the Stage appears in the selected language. If not, the text fields already on the Stage are blank.

Enter Asian characters on a Western keyboard

With Flash, you can use Input Method Editors (IMEs) and standard Western keyboards to enter Asian characters on the Stage. Flash supports more than two dozen IMEs.

For example, to create a website that reaches a broad range of Asian viewers, you can use a standard Western (QWERTY) keyboard and change the IME to create text in Chinese, Japanese, and Korean.

Note: This feature affects only text input on the Stage, not text entered in the Actions panel. This feature is available for all supported Windows operating systems and Mac OS X.
  1. Select Edit > Preferences (Windows) or Flash > Preferences (Macintosh), and click Text in the Category list.
  2. Under Input Method, select one of the options to input characters from a Western keyboard. The default is Chinese and Japanese and it should also be selected for Western languages.

Publishing multilanguage FLA files

When you save, publish, or test the FLA file, a folder with an XML file is created for each available language you selected in the Strings panel. The default location for the XML folders and files is the same folder indicated as the SWF publish path. If no SWF publish path was selected, the XML folder and files are saved in the folder in which the FLA file is located. For example, if you have a file named Test in the mystuff folder, and you selected English (en), German (de), and Spanish (es) as active languages, and you did not select a SWF publish path, when you save the FLA file, the following folder structure is created:

\mystuff\Test.fla 
\mystuff\de\Test_de.xml 
\mystuff\en\Test_en.xml 
\mystuff\es\Test_es.xml

When you start a SWF file, you also need to start the associated XML files with the string translations in the web server. The first frame that contains text cannot appear until the entire XML file is downloaded.

Manually replace strings at publish time

Manually replace strings by using the Stage language when you publish your Flash SWF file. This method uses the Stage language to replace all instances of input and dynamic text with an associated string ID. In this case, text strings are only updated when you publish the SWF file; language detection is not automatic, and you must publish a SWF file for each language to support.

  1. Select Window > Other Panels > Strings, and click Settings.
  2. Select the Replace Strings Automatically At Runtime check box.

Use automatic language detection with the default language

You can change the default runtime language to any language that you selected as an available language. When automatic language detection is on, and you view the SWF file on the system that uses the language, any system that is set to a language other than one of the active languages uses the default language. For example, if you set your default language to English and you select ja, en, and fr as active languages, users who have their system language set to Japanese, English, or French automatically see text strings in their chosen language. However, users who have their system language set to Swedish, which is not one of the selected languages, automatically see text strings in the default language you selected—in this case, English.

  1. Select Window > Other Panels > Strings, and click Settings.
  2. In the Default language menu, select the default language. This must be a language you added as an available language.
  3. To enable automatic language detection, select Replace Strings Automatically At Runtime, and click OK.

Flash generates the following ActionScript®, which stores the language XML file paths. Use this code as a starting point for your own language detection script.

import mx.lang.Locale; 
Locale.setFlaName("<flaFileName>"); 
Locale.setDefaultLang("langcode"); 
Locale.addXMLPath("langcode", "url/langcode/flaname_langcode.xml");
Note: The ActionScript code that the Strings panel generates does not use the Locale.initialize function. Decide how to call this function based on the language detection customizations your project requires.

Use custom language detection

To access the language XML files to control text replacement at a time that you designate, create your own custom component or use ActionScript code. For example, you might create a pop‑up menu that lets users select a language for viewing content.

For information on writing ActionScript code to create custom language detection, see About the Strings panel in Learning ActionScript 2.0 in Adobe Flash.

  1. Select Window > Other Panels > Strings, and click Settings.
  2. In the Default Language menu, select the default language.

    This must be a language you added as an available language.

  3. Select the Replace Strings Via ActionScript check box, and click OK.

    Flash generates the following ActionScript code, which stores the language XML file paths. Use this code as a starting point for your own language detection script.

    import mx.lang.Locale; 
    Locale.setFlaName("<flaFileName>"); 
    Locale.setDefaultLang("langcode"); 
    Locale.addXMLPath("langcode", "url/langcode/flaname_langcode.xml");
Note: The ActionScript that the Strings panel generates does not use the Locale.initialize function. Decide how to call this function based on the language detection customizations your project requires.