Example: Create a locale

This example contains the steps necessary for creating a locale. The example also shows how to enable the locale.

Steps for enabling the locale are:

  1. Create (or have ) a library and a source physical file.
  2. Copy an existing locale source file definition member (to a library and source physical file).
  3. Edit the copied locale source file member if you need to customize any of the categories within the locale source.
  4. Create the locale object.
  5. Enable the locale object by using system values or parameters on the user profile.

Step 1. Create a library and source physical file

The library and source physical file are needed to store the locale source file member. The System-supplied locale source definition files topic includes a list of the locale source file members that are included in i5/OS™.

  1. Type CRTLIB and press the F4 (prompt) key.
  2. Type localelib for the name of the library and press the Enter key.

There is now a library called localelib.

Next, create a source physical file.

  1. Type CRTSRCPF and press the F4 (prompt) key.
  2. Type localesrc for the file name and press the Enter key.

There is now a source physical file (localesrc) created in library localelib.

Step 2. Copy an existing locale source definition

IBM-supplied locale source definition file members are located in library QSYSLOCALE, source physical file QLOCALESRC. See System-supplied locale source definition files for a list of all IBM-supplied locale source files. In this example, member EN_US, a locale for the English language, is copied.

  1. Type CPYF and press the F4 (prompt) key.
  2. Type the values shown on the following display.
    +--------------------------------------------------------------------------------+
    |Copy File (CPYF)                                                                |
    |                                                                                |
    |Type choices, press Enter.                                                      |
    |                                                                                |
    |From file  . . . . . . . . . . .   QLOCALESRC    Name                           |
    |Library  . . . . . . . . . . .     QSYSLOCALE  Name, *LIBL,*CURLIB              |
    |To file  . . . . . . . . . . . .   LOCALESRC_    Name, *PRINT                   |
    |Library  . . . . . . . . . . .     LOCALELIB_  Name, *LIBL,*CURLIB              |
    |From member  . . . . . . . . . .   EN_US         Name, generic*,*FIRST, *ALL    |
    |To member or label . . . . . . .   EN_US_____    Name, *FIRST,*FROMMBR          |
    |Replace or add records . . . . .   *ADD____      *NONE, *ADD,*REPLACE           |
    |Create file  . . . . . . . . . .   *YES          *NO, *YES                      |
    |Record format field mapping  . .   *MAP__        *NONE, *NOCHK,*CVTSRC          |
    +--------------------------------------------------------------------------------+

    The values entered copy the EN_US member to the source physical file localesrc in library localelib.

    Note: When you copy a file that is tagged with a CCSID, you need to use the FMTOPT(*MAP) parameter to ensure that the copied source is converted to the CCSID of the "to file". The FMTOPT parameter can be seen by scrolling ahead.

Step 3. Edit the copied locale source definition

If you want to use the IBM-supplied locale as it is included, you do not need to change it. You can go to the next step, create the locale object. However, in this example we will edit the EN_US member to set the time-of-day keywords used in the LC_TOD category.

Note: The LC_TOD category is included with the keywords having no values. See the LC_TOD Category to view the LC_TOD source as included by IBM®.

In this example, Source Entry Utility (SEU) is used to edit the locale. You can use SEU or an equivalent editor.

  1. Type STRSEU (Start Source Entry Utility) and press the F4 (prompt) key.
  2. Type the source file name (localesrc), library name (localelib), and source member name (EN_US) as shown on the following display.
    +--------------------------------------------------------------------------------+
    |Start Source Entry Utility (STRSEU)                                             |
    |                                                                                |
    |Type choices, press Enter.                                                      |
    |                                                                                |
    |Source file  . . . . . . . . . .   localesrc     Name, *PRV                     |
    |Library  . . . . . . . . . . .     localelib_  Name, *LIBL, *CURLIB, *PRV       |
    |Source member  . . . . . . . . .   EN_US_____    Name, *PRV, *SELECT            |
    +--------------------------------------------------------------------------------+
  3. Press the Enter key. The following display appears:
    +--------------------------------------------------------------------------------+
    |COLUMNS . . . :    1  71           EDIT      LOCALELIB/LOCALESRC                |
    |SEU==>  F_LC_TOD      EN_US                                                     |
    |FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+...6 ...+... 7    |
    |*************** BEGINNING OF DATA*************************************          |
    |5967.00 comment_char <percent-sign>                                             |
    |5968.00 escape_char  <slash>                                                    |
    |5969.00                                                                         |
    |5970.00 %                                                                       |
    |5971.00 % 5716SS1         (C) COPYRIGHT IBM CORP. 1991,1996                     |
    |5972.00 % ALL RIGHTS RESERVED.                                                  |
    |5973.00 % US GOVERNMENT USERS RESTRICTED RIGHTS -                               |
    |5974.00 % USE, DUPLICATION OR DISCLOSURE RESTRICTED                             |
    |5975.00 % BY GSA ADP SCHEDULE CONTRACT WITH IBM CORP.                           |
    |5976.00 %                                                                       |
    |5977.00 % LICENSED MATERIALS-PROPERTY OF IBM                                    |
    |5978.00 %                                                                       |
    |5979.00 % FILE NAME  :    EN_US                                                 |
    |5980.00 %                                                                       |
    |5981.00 % COUNTRY/REGION: UNITED STATES                                         |
    |5982.00 %                                                                       |
    |                                                                                |
    |F3=EXIT   F4=PROMPT   F5=REFRESH   F9=RETRIEVE   F10=CURSOR   F11=TOGGLE        |
    |F16=REPEAT FIND       F17=REPEAT CHANGE          F24=MORE KEYS                  |
    |                                        (C) COPYRIGHT IBM CORP.1981, 1996.      |
    +--------------------------------------------------------------------------------+
  4. Use the SEU search function to locate LC_TOD. After the search completes, the following display appears.

    As you can see, all LC_TOD category keywords have values of 0 and no descriptive names declared for tname and dstname.

    +--------------------------------------------------------------------------------+
    |COLUMNS . . . :    1  71           EDIT      LOCALELIB/LOCALESRC                |
    |SEU==>       EN_US                                                              |
    |FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+...6 ...+... 7    |
    |6519.00                                                                         |
    |6520.00 LC_TOD                                                                  |
    |6521.00                                                                         |
    |6522.00 tzdiff   0                                                              |
    |6523.00 tname    ""                                                             |
    |6524.00 dstname  ""                                                             |
    |6525.00 dststart 0,0,0,0                                                        |
    |6526.00 dstend   0,0,0,0                                                        |
    |6527.00 dstshift 0                                                              |
    |6528.00                                                                         |
    |6529.00 END LC_TOD                                                              |
    |****************** END OF DATA****************************************          |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |F3=EXIT   F4=PROMPT   F5=REFRESH   F9=RETRIEVE   F10=CURSOR  F11=TOGGLE         |
    |F16=REPEAT FIND       F17=REPEAT CHANGE          F24=MORE KEYS                  |
    |STRING LC_TOD FOUND.                                                            |
    +--------------------------------------------------------------------------------+
  5. Type the following values for the LC_TOD keywords. If you need more detailed information about this category, see LC_TOD Category.
    tzdiff
    Time zone difference in minutes. Type 360. This is the difference in the number of minutes between Greenwich mean time and the central time zone of the United States.
    tname
    Specifies the string used for the time zone name. Type "<C><E><N><T><R><A><L>".
    dstname
    The string used for the daylight saving time name. Type "<C><D><T>" to mean Central Daylight Time.
    dststart
    Four integers representing the start date for daylight saving time. Type 4,0,23,0. This string of integers means that daylight saving time starts the fourth month of the year, the twenty-third day of the month, and 0 seconds after midnight local standard time.
    dstend
    Four integers representing the end date for daylight saving time. Type 10,3,6,0. This string of integers means that daylight saving time ends the tenth month of the year, the beginning of the third week, the sixth day of the week, and 0 seconds after midnight local standard time.
    dstshift
    An integer value representing the daylight saving time shift in seconds. Type 3600.

    The SEU edit screen should match the screen below.

  6. Press the Enter key to make the changes to the EN_US locale member.
    +--------------------------------------------------------------------------------+
    |COLUMNS . . . :    1  71           EDIT      LOCALELIB/LOCALESRC                |
    |SEU==>       EN_US                                                              |
    |FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+...6 ...+... 7    |
    |6519.00                                                                         |
    |6520.00 LC_TOD                                                                  |
    |6521.00                                                                         |
    |6522.00 tzdiff   360                                                           |
    |6523.00 tname   "<C><E><N><T><R><A><L>"                                         |
    |6524.00 dstname  "<C><D><T>"                                                    |
    |6525.00 dststart 4,0,23,0                                                       |
    |6526.00 dstend   10,3,6,0                                                       |
    |6527.00 dstshift 3600                                                           |
    |6528.00                                                                         |
    |6529.00 END LC_TOD                                                              |
    |****************** END OF DATA ****************************************         |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |F3=EXIT   F4=PROMPT   F5=REFRESH   F9=RETRIEVE   F10=CURSOR   F11=TOGGLE        |
    |F16=REPEAT FIND       F17=REPEAT CHANGE          F24=MORE KEYS                  |
    |STRING LC_TOD FOUND.                                                            |
    +--------------------------------------------------------------------------------+
  7. Save the member and exit SEU.

You have now copied the IBM-supplied locale source member and customized the LC_TOD category.

Step 4. Create the locale object

  1. Type CRTLOCALE on any command line and press the F4 (prompt) key. The Create Locale (CRTLOCALE) screen appears.
  2. Type the locale path name (path name includes the location of as well as the name of the locale source member) in the locale name field.
  3. Next, type the source file path name (location and name of the source physical file and the member name) in the source file path name field.
    Notes:
    1. Make sure that the locale source file you are using has the same characters defined as does the CCSID you specify on the CRTLOCALE command. If they do not have the same characters available, unpredictable results can occur. For example, the EN_US source file has lower case letters defined. However, the lower case letters are not available in CCSID 290.
    2. When creating locale objects, it is recommended to make the CCSID part of the locale object name. For example, EN_US created with CCSID 37 can be named EN_US37.
    +--------------------------------------------------------------------------------+
    |Create Locale (CRTLOCALE)                                                       |
    |                                                                                |
    |Type choices, press Enter.                                                      |
    |                                                                                |
    |Locale name  . . . . . . . . . . > '/qsys.lib/localelib.lib/en_us.locale'____   |
    |______                                                                          |
    |Source file path name  . . . . . > '/qsys.lib/localelib.lib/localesrc.file/en   |
    |_us.mbr'                                                                        |
    |Coded character set ID . . . . . > 37________    1-65533, *JOB                  |
    |Generation severity level  . . .   10____        10, 20                         |
    |Text 'description' . . . . . . .   my version of locale EN_US - contains my c   |
    |hanges_                                                                         |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |Bottom                                                                          |
    |F3=Exit   F4=Prompt   F5=Refresh   F10=Additional parameters  F12=Cancel        |
    |F13=How to use this display        F24=More keys                                |
    |                                                                                |
    |                                                                                |
    +--------------------------------------------------------------------------------+
  4. Press the Enter key to complete the creation of the locale object named EN_US in the library LOCALELIB

Step 5. Enable the locale object

Locales can be enabled system-wide using the QLOCALE system value or for individual users by changing their user profile. To enable system-wide, make EN_US the value for QLOCALE. In this example locale support is enabled for one user.

  1. Type CHGUSRPRF and press the F4 (prompt) key.
  2. Specify your userid and then press the Enter key.

    In the following portion of the Change User Profile display, the LOCALE parameter now has a value indicating that EN_US is the specified locale to be used by your userid.

    +--------------------------------------------------------------------------------+
    |+ for more values                                                               |
    |Locale . . . . . . . . . . . . .  QSYS.LIB/LOCALELIB.LIB/EN_US.LOCALE______     |
    |_______                                                                         |
    +--------------------------------------------------------------------------------+

After your user profile has been changed, any jobs initiated by your userid have the EN_US locale associated with those jobs. The LANG environment variable is also initialized to the name of the locale.

Related concepts
Work with locales
System-supplied locales and recommended CCSIDs
LC_TIME category