Using National Language Support

This chapter provides an overview of locales and discusses how to:

Click to jump to parent topicUnderstanding Locales

National Language Support (NLS) is provided through the concept of locales. A locale is a set of local preferences for language, currency, and the presentation of dates and numbers. For example, one locale may use English, dollar currency, dates in dd/mm/yy format, numbers with commas separating the thousands, and a period for the decimal place.

A locale contains:

Click to jump to parent topicSelecting Locales

SQR provides predefined locales such as US-English, UK-English, German, French, and Spanish. You can define additional locales by editing any .ini file.

With the ALTER-LOCALE command, you can select a locale at the beginning of the program or anywhere else. Different parts of the program can use different locales.

Select a locale with a command such as this:

alter-locale locale = 'German'

Click to jump to parent topicDefining a Default Locale

You can define a default locale in any .ini file. Most or all of your programs can use the same locale, and specifying the default locale makes it unnecessary to specify the locale in every program.

When you install SQR, the default locale is set to the reserved locale called System . System is not an actual locale. It defines the behavior of older versions of SQR, before NLS was added. The preferences in the system locale are hard-coded in the product and cannot be set or defined in the pssqr.ini; however, you can alter system settings at runtime by using ALTER-LOCALE. The date preferences depend on the database that you are using. Therefore, date format preferences in the system locale are different for every database that you use with SQR.

Note. If you are running SQR outside of the PeopleSoft Process Scheduler, the PS_HOME environment variable must be set to a proper PeopleSoft installation.

Different sites can have different locales as the default. For example, an office in Paris might use the French locale, and an office in London might use the UK-English locale. To adapt a program to any location, use the default locale. The program automatically uses the local preferences, which are specified in the pssqr.ini file of the machine on which it is run. For example, you can print the number 5120 by using the following command:

print #invoice_total () edit '9,999,999.99'

The setting of the default locale in the pssqr.ini file controls the format. In London, the result might be 5,120.00, and in Paris it might be 5.120,00. The delimiters for thousands and the decimal—the comma and the period—are switched automatically according to the preferences of the locale.

Note. Changing the settings of the default locale can change the behavior of existing programs. For example, if you change the default locale to French, programs that used to print dates in English may now print them in French. Be sure that you review and test existing programs when making a change to the default locale.

Click to jump to parent topicSwitching Locales

You can switch from one locale to another any number of times while the program is running. This technique is useful for writing reports that use multiple currencies, or reports that have different sections for different locales.

To switch to another locale, use the ALTER-LOCALE command. For example, to switch to the Spanish locale:

alter-locale locale = 'Spanish'

From this point in the program, the locale is Spanish.

Consider this code example:

begin-procedure print_data_in_spanish ! Save the current locale let $old_locale = $sqr-locale ! Change the locale to "Spanish" alter-locale locale = 'Spanish' ! Print the data do print_data ! restore the locale to the previous setting alter-locale locale = $old_locale end-procedure

In this code example, the locale is switched to Spanish and later restored to the previous locale before it was switched. To do that, the locale setting before it is changed is read in the$sqr-locale reserved variable and stored in $old_locale. The value of $old_locale is then used in the ALTER-LOCALE command at the end of the procedure.

Click to jump to parent topicModifying Locale Preferences

With the ALTER-LOCALE command, you can modify any individual preference in a locale. The ALTER-LOCALE command affects only the current program. It does not modify the pssqr.ini file.

Here is a code example of how you can modify default preferences in a locale:

alter-locale date-edit-mask = 'Mon-DD-YYYY' money-edit-mask = '$$,$$$,$$9.99'

To restore modified locale preferences to their defaults, reselect the modified locale. For example, suppose that the locale was US-English and the date and money edit masks were modified by using the preceding code. The following code resets the changed date and money edit masks:

alter-locale locale = 'US-English'

Click to jump to parent topicSpecifying NUMBER, MONEY, and DATE Keywords

The DISPLAY, MOVE, PRINT, and SHOW commands enable you to specify the NUMBER, MONEY, and DATE keywords in place of an explicit number or date edit mask. These keywords can be useful in two cases.

The first case is when you want to write programs that automatically adapt to the default locale. By using the NUMBER, MONEY, and DATE keywords, you instruct SQR to take these edit masks from the default locale settings.

The second case is when you want to specify number, money, and date formats once at the top of the program and use these formats throughout the report. In this case, you define these formats with an ALTER-LOCALE command at the top of the program. When you use the NUMBER, MONEY, and DATE keywords later in the program, they format number, money, and date outputs with the masks that you defined in the ALTER-LOCALE command.

Whether you set the locale in the pssqr.ini file or in the program, these keywords have the same effect. In the following code example, these keywords are used with the PRINT command to produce output for the US-English and French locales:

let #num_var = 123456 let #money_var = 123456 let $date_var = strtodate('20040520152000') ! set locale to US-English alter-locale locale = 'US-English' print 'US-English locale' (1,1) print 'With NUMBER keyword ' (+1,1) print #num_var (,22) NUMBER print 'With MONEY keyword ' (+1,1) print #money_var (,22) MONEY print 'With DATE keyword ' (+1,1) print $date_var (,22) DATE! set locale to French ALTER-LOCALE locale = 'French' print 'French locale' (+2,1) print 'With NUMBER keyword ' (+1,1) print #num_var (,22) NUMBER print 'With MONEY keyword ' (+1,1) print #money_var (,22) MONEY print 'With DATE keyword ' (+1,1) print $date_var (,22) DATE

Here is the program output:

US-English locale With NUMBER keyword 123,456.00 With MONEY keyword $ 123,456.00 With DATE keyword May 20, 2004 French locale With NUMBER keyword 123.456,00 With MONEY keyword 123.456,00 F With DATE keyword 20 Mai 2004

See Also

Enterprise PeopleTools 8.49 PeopleBook: SQR Language Reference for PeopleSoft