6.1.2.86. SetLanguage (dialplan application)
1. SetLanguage - this application allows you to change the used language.
NOTE: This application is valid for Asterisk version 1.0.9 and above.
Syntax:
SetLanguage(language)
Purpose and usage
The purpose of this application is to give you the possibility to change the preferable language. This also could be done manually in the configuration file of the channel oyu use (iax.conf, sip.conf or mgcp.conf). However may be it is easier to do this by using the SetLanguage application.
With this application you can state your preferable language. The Asterisk PBX could use this to determine and play the sound files recorded in the desired language.
If your preferable language is set to de(German), then the system will try to play the sound files from the /var/lib/asterisk/sounds/de directory. The messages in these files are recorded in German. If your language is set to fr(French), the system will try to play the sound files from the /var/lib/asterisk/sounds/fr directory. The messages in these files are recorded in French. And so on.
If the language directory does not exist, the system will play the general sound files, which are placed in the /var/lib/asterisk/sounds.
Also, if there is no directory for your language, you can create one. Then you can record sound messages in your own language and to put them into the directory.
So, your services could become more personalized and user friendly.
When you set a language, you have to use the two letters abbreviation.
Prerequisites
To use this application you need a working Asterisk PBX with registered users in iax.conf, sip.conf or mgcp.conf(It depends on which protocol you would like to use) and made extensions.
To see how the application works we recommend to use our
IAX softphone Idefisk. You can download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.
Asterisk PBX configurations
This is only an example of what for you can use this application. Of course you can use it and for other things.
We need one registered users in iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.
So, we have registered the user user1
Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.
On the picture above you can see our extensions.conf file.
In our example when somebody dials 1010, the call will be answered by the Answer application. The next executed extension will be the one which contains the SendText application. It will send us, a text message with the current language. In our example the message is The current language is: en. So the language is English. To check the current language, we use the variable ${LANGUAGE}. Then we have the Wait application. Just to give enough time to the user to see the message. We have set the time to 5 seconds.
The extension with priority 4 is the one with the SetLanguage application. We will set the language to German by its help.
Then we have another Wait application.
Finally, we have again SendText application. It will help us to check whether the change is successful.
A new message will appear on the screen of the caller. In our case it is: The new language is: de. This means that the new language is German.
NOTE: The desired language has to be written with the two letters abbreviation.
In order to be sure, that the Asterisk PBX will hang up the line after the conversation is over, it is always a good idea to make an extension for hanging up.
2. Screenshots of what you can see on your Idefisk and on the CLI of the Asterisk PBX
3. Additional information
For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.
This application is tested with our
IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.
If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX
Add Comment |