Upgrade 3CX to v18 and get it hosted free!

Asterisk multi-language

Author image

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.

! 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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.