Asterisk multi-language

Setting up a Multi-Language Asterisk Installation


Many Asterisk Dialplan commands cause Asterisk to play sound files from the /var/lib/asterisk/sounds directory structure. Many of these sounds are recordings of phrases and sentences such as, "Please hold while I try that extension." Asterisk supports the automatic selection of different language editions of these sound files.

When Asterisk looks for a particular sound file, such as transfer.gsm, it will first look in a subdirectory corresponding with the currently selected language. For example, if the currently selected language "de", the Asterisk will first look for the file /var/lib/asterisk/sounds/de/transfer.gsm. If this file or the "de" directory does not exist, then Asterisk will look for the file /var/lib/asterisk/sounds/transfer.gsm, which is usually an English-language default recording.

If an Asterisk command specifies a sound file in a subdirectory, Asterisk looks in that subdirectory for the language subdirectory. For example, the SayDigits command may play the sound file "digits/6". Asterisk will, if the language code is "de", first look for /var/lib/asterisk/sounds/digits/de/6.gsm before falling back to /var/lib/asterisk/sounds/digits/6.gsm.

NOTE: The file structure for 1.4 is different than for 1.2!
NOTE: The file structure for 1.6 is the 'new layout' by default!
Asterisk 1.4 supports a new layout for sound files in multiple languages; instead of the alternate-language files being stored in subdirectories underneath the existing files (for French, that would be digits/fr, letters/fr, phonetic/fr, etc.) the new layout creates one directory under /var/lib/asterisk/sounds for the language itself, then places all the sound files for that language under that directory and its subdirectories. This is the layout that will be created if you select non-English languages to be installed via menuselect, HOWEVER Asterisk 1.4 does not default to this layout and will not find the files in the places it expects them to be. If you wish to use this layout, make sure you put 'languageprefix=yes' in the 'options' section in your /etc/asterisk/asterisk.conf file, so that Asterisk will know how the files were installed. For asterisk 1.6, the new layout is the default and you need to set 'languageprefix=no' to get the old behaviour.


Setting the Language

The default language for a particular channel is set in that channel's configuration file. Look for a setting like:

language=en

in the [general] section.

You may specify any text (up to 20 characters long) as the language code. When playing sounds from the /var/lib/asterisk/sounds directory, Asterisk will look for a subdirectory with the same name as the currently selected language.

You can override the channel's default language using the SetLanguage command in your Dialplan. You may use the ${LANGUAGE} channel variable to discover what the currently selected language code is.

(:exclaim:) The language code specified in the channel configuration files and using the SetLanguage command is quite separate from the country code specified in the indications.conf file used to select country-specific tones (dialtone, ring tone, busy tone etc) by the Playtones command.

Dialplan Commands

The Dialplan Commands that use the multi-language feature of Asterisk include:


Tip

This "language selection" feature does not have to be restricted just to making different language files. You could, for example, choose to have your voice prompts recorded by a male speaker and a female speaker. A channel configuration file might set:

language=female

and you could override that with a call to SetLanguage(male). If you requested Asterisk to play the 'transfer' sound file, then Asterisk will look in /var/lib/asterisk/sounds/male/transfer.gsm directory, and if not found, revert to the default /var/lib/asterisk/sounds/transfer.gsm.

See also



Asterisk | Configuration

Setting up a Multi-Language Asterisk Installation


Many Asterisk Dialplan commands cause Asterisk to play sound files from the /var/lib/asterisk/sounds directory structure. Many of these sounds are recordings of phrases and sentences such as, "Please hold while I try that extension." Asterisk supports the automatic selection of different language editions of these sound files.

When Asterisk looks for a particular sound file, such as transfer.gsm, it will first look in a subdirectory corresponding with the currently selected language. For example, if the currently selected language "de", the Asterisk will first look for the file /var/lib/asterisk/sounds/de/transfer.gsm. If this file or the "de" directory does not exist, then Asterisk will look for the file /var/lib/asterisk/sounds/transfer.gsm, which is usually an English-language default recording.

If an Asterisk command specifies a sound file in a subdirectory, Asterisk looks in that subdirectory for the language subdirectory. For example, the SayDigits command may play the sound file "digits/6". Asterisk will, if the language code is "de", first look for /var/lib/asterisk/sounds/digits/de/6.gsm before falling back to /var/lib/asterisk/sounds/digits/6.gsm.

NOTE: The file structure for 1.4 is different than for 1.2!
NOTE: The file structure for 1.6 is the 'new layout' by default!
Asterisk 1.4 supports a new layout for sound files in multiple languages; instead of the alternate-language files being stored in subdirectories underneath the existing files (for French, that would be digits/fr, letters/fr, phonetic/fr, etc.) the new layout creates one directory under /var/lib/asterisk/sounds for the language itself, then places all the sound files for that language under that directory and its subdirectories. This is the layout that will be created if you select non-English languages to be installed via menuselect, HOWEVER Asterisk 1.4 does not default to this layout and will not find the files in the places it expects them to be. If you wish to use this layout, make sure you put 'languageprefix=yes' in the 'options' section in your /etc/asterisk/asterisk.conf file, so that Asterisk will know how the files were installed. For asterisk 1.6, the new layout is the default and you need to set 'languageprefix=no' to get the old behaviour.


Setting the Language

The default language for a particular channel is set in that channel's configuration file. Look for a setting like:

language=en

in the [general] section.

You may specify any text (up to 20 characters long) as the language code. When playing sounds from the /var/lib/asterisk/sounds directory, Asterisk will look for a subdirectory with the same name as the currently selected language.

You can override the channel's default language using the SetLanguage command in your Dialplan. You may use the ${LANGUAGE} channel variable to discover what the currently selected language code is.

(:exclaim:) The language code specified in the channel configuration files and using the SetLanguage command is quite separate from the country code specified in the indications.conf file used to select country-specific tones (dialtone, ring tone, busy tone etc) by the Playtones command.

Dialplan Commands

The Dialplan Commands that use the multi-language feature of Asterisk include:


Tip

This "language selection" feature does not have to be restricted just to making different language files. You could, for example, choose to have your voice prompts recorded by a male speaker and a female speaker. A channel configuration file might set:

language=female

and you could override that with a call to SetLanguage(male). If you requested Asterisk to play the 'transfer' sound file, then Asterisk will look in /var/lib/asterisk/sounds/male/transfer.gsm directory, and if not found, revert to the default /var/lib/asterisk/sounds/transfer.gsm.

See also



Asterisk | Configuration
Created by: oej, Last modification: Fri 17 of Jul, 2009 (13:53 UTC) by fhackenberger
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+