How to Create a new Locale in OpenSolaris

In the last blog I shortly described the history of locales and the reason why a a new workspace for locales has been created. Now I am going to show you how to work with the locale workspace and how to create a new UTF-8 locale.

The following instructions are for OpenSolaris 2009.06 (and later). Building in older versions of Solaris/OpenSolaris is possible, but there would be differences in installation of the build tools.

The locale workspace is a part of Nevada Globalization project. The workspace can be built as part of the project or stand-alone. I will describe the stand-alone way.

To be able to build the workspace we need build tools. All necessary build tools are part of OpenSolaris, but not installed by default. So, we need to install them:

$ pfexec pkg install SUNWmercurial SUNWgmake SUNWant sunstudio
$ export CC=/opt/sunstudio12.1/bin/cc

We need to clone the workspace to our machine:

$ hg clone ssh://anon@hg.opensolaris.org//hg/nv-g11n/locale

OpenSolaris is installed from IPS packages. IPS packages do not have a disk file representation, the packages exist only in IPS server. To be able to test the new locales you need an IPS server. A local IPS server is a part of each OpenSolaris installation, but it is disabled by default. First you need to enable the service

$ pfexec svcadm restart pkg/server
and setup the server as a primary authority
$ pfexec pkg set-publisher -P -O http://localhost local

Now everything is ready for compilation

     $ make 
 or  $ make all

To install the new packages you first need to send them to the IPS server

$ make PKG_REPO=http://localhost:80 ips
The compilation of all locales takes ~4.5 hours (Intel Core 2 3GHz, 'make -j2 ...'). Or you can compile just one package
$ make PKG_REPO=http://localhost:80 PKGS=SUNWlang-xx ips

Now you can install the new package:

$ pfexec pkg install SUNWlang-xx@1-1

Each package in IPS server has an unique FMRI identifier. The FMRI includes the name, version and a timestamp for the package. The builded packages have version @1-1. For existing packages it is usually in collision with package entire, which is installed by default. The package depends on specific version of the SUNWlang-\* packages (entire is metapackage and is used for upgrade purposes). Because version required by the entire package is changing with each build, there is not simple solution of the this conflict.

One way is to modify the locale/mk/pkgs.mk:cmd_pkgsend command and change '@1-1' to the same version like your 'entire' has:

$ pkg info entire|grep FMRI
        FMRI: pkg://opensolaris.org/entire@0.5.11,5.11-0.111:20090518T052643Z
$ sed -ie 's/@1-1/@0.5.11-0.111/' misc/mk/pkgs.mk

 

Another solution is to uninstall 'entire' package:

$ pfexec pkg uninstall entire

 

First way needs to modify the build scripts after solaris upgrade, the second could make upgrade problems.

It could happen that the @1-1 version of your package is in confilict with package entire. You can modify locale/mk/pkgs.mk: cmd_pkgsend to build the same version like entire needs or uninstall the entire package.

We are able to compile existing locales. Now it is time to create a new one. The simpliest situation is when you need to to add a new UTF-8 locale and at the same time you are satisfied with the CLDR data. Each locale has its own specification file locale/locale/<locale>.spec

The file contains definitions, or otherwise say attributes, of the locale. List of all possible attributes and default values is in the file locale/README. If an attribute is missing in the file, there will be used a default value.

For our new locale we will use only default values of all attributes, so it is enough to create an empty file

$ touch locale/locale/xx_YY.UTF-8.spec

Now you can install the new locale

$ make PKG_REPO=http://localhost:80 PKGS=SUNWlang-xx ips
$ pfexec pkg install SUNWlang-xx@1-1

and the game is over - enjoy your new locale :)

Next week I am going to write about how to modify the locale. 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Solaris l10n & i18n, locales, keyboards, fonts and related topics.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today