Changing the application locale dynamically

Blueworx Voice Response for AIX: Deploying and Managing VoiceXML and Java Applications introduces the concept of current locale, and suggests how you might design an application that changes the current locale dynamically. This section tells you how to do it.

Setting the locale

You can set the locale to be used while the application is running, either on the basis of the calling number or some other criteria (for example, a menu that asks the caller which language they want).

The WVR class has a currentLocale property. When WVR.makeCall() or WVR.waitForCall() is invoked, the currentLocale property is set to the default locale (see Blueworx Voice Response for AIX: Deploying and Managing VoiceXML and Java Applications). To change the locale used by the application, during the application, use the WVR.setCurrentLocale() method within voiceMain(). Setting the current locale in this way does not change the value of the locale in the ApplicationProperties object. The current locale does not affect any MediaType objects that have locale individually specified.

When an application finishes with the call and starts to handle a new call, the default locale is used again, rather than a locale that the application has switched to during the previous call.

Resetting the current locale to the default locale

To reset the locale back to the default locale during a call, set the value of the currentLocale property of the WVR object to null.