Aros/Developer/Docs/Libraries/Locale

Introduction
here is a global environment variable (Language) that holds the current active language.

You can check this yourself by typing "getenv language" (without the quotes) into a shell. Or it can be used in a script as variable $Language.

It can also be done programming using the OpenLocale function (with NULL as parameter to return the current locale information in struct Locale)

System
The locale.library provides us tools to localize applications. Localized strings are stored in separate languages catalogs files, under Catalogs directories. AROS Development Environment macros can build the required files. This document gives you a work-flow to localize applications or localize existing applications or create catalogs files for existing localized applications.

For each language supported, the system has a LOCALE:Languages/ file: LOCALE:Languages/klingon.language

System translations are in LOCALE:Catalogs/ language directories: LOCALE:Catalogs/klingon/

Each application needs its proper Catalogs directory: my_app/Catalogs/

Translation files are in languages directories: my_app/Catalogs/klingon/my_app.catalog

Appplications
Each application supporting localization has its own catalogs directory: AROS/Contrib/my_app/catalogs

Strings are initially stored in a catalog description file: AROS/Contrib/my_app/catalogs/my_app.cd

This file is structured as: MSG_TITLE (//) My Application MSG_MY_MESSAGE (//) My application message ...

Translations are stored in catalog translation files: AROS/Contrib/my_app/catalogs/klingon.ct

Structured as: MSG_TITLE tlhIngan maH MSG_MY_MESSAGE Sujatlh 'e' yImev ...
 * 1) version $VER: my_app.catalog 1.0 (23.05.2004)
 * 2) language klingon
 * 3) codeset 0

The catalogs build file

Localization is provided by: AROS/Contrib/my_app/locale.c

AROS/contrib/my_app/locale.h

Application: _(MSG_MY_TITLE)

As STRPTR.

Or with: __(MSG_MY_MESSAGE)

As IPTR (1) The application source file

In AROS/Contrib/my_app/my_app.c, initialize locale with:

... ...

Use the strings names from the .cd file. For instance, on a Zune application: MUIA_Application_Title, __(MSG_TITLE), ... } The application build file Add the locale file target to the FILE section of AROS/Contrib/my_app/mmakefile.src: FILES   := my_app \ ...              locale

Add the pre-requisite target for locale: ... Build the locale AROS/
 * 1) MM- my_app: \
 * 1) MM my_app-catalogs

To build the application and locale files: make my_app

To update the translation (.ct) files: make my_app-catalogsWarning:	If you are updating the description (.cd) files, build my_app target to update its strings file.

Build System
AROS Metamake builds required files with its build file present as: AROS/Contrib/my_app/catalogs/mmakefile.src

FlexCat
FlexCat is a tool to create Amiga localization catalogs, as well as source and header files, out of catalog descriptions.

The version in AROS/tools is 2.4, with a developers.readme saying to treat it as freeware with source code, but not to fork it. The history file tells us that version 2.4 is from 28 November 1999. Not all websites referred to in the documentation still exist, but flexcat indeed supports the 2.4 version, with no mention of further development. Is a port a fork? If not, does a former port become a fork e.g. just because AROS becomes 68k? What if there originally was only one port, but someone else does another one - who is the forker? Maybe the author was just too imprecise and should have provided a definition of fork...

1 The AROS project stamps are for 7 March 2009, so there may well have been changes for the AROS version over the last decade.

2 The last release on Aminet is version 2.7 on 29 June 2010, by the project, which claims a copyright starting in 2002.

The original homepage is outdated. It's now a GPL licensed product which is maintained here. Of course the 2.7 distribution does not contain the source code, because the project is Open Source and the source code is available for everybody. The release archives contain binaries only for all supported platforms.


 * Update the sources in AROS from a stable release of FlexCat
 * Make it buildable again, perhaps my merging in commits from prior commits.
 * C_h_orig.sd is no longer available in current FlexCat. Find a replacement which works with the AROS build-system.
 * Bring back all fixes for AROS to the current trunk of FlexCat. Either bei joining the project on Sourceforge or sending it to the maintainer.

We would appreciate if you would join the team and commit the changes to the SVN repository on sourceforge.net. Just ask Jens Langer (damato#light-speed.de) to add you the list of developers.

Optionally: wait till the "vendor" branch is available in AROS repository and work with that.

Examples

 * 1) ifndef _LOCALE_H_
 * 2) define _LOCALE_H_

/*   Copyright © 2003-2004, The AROS Development Team. All rights reserved. $Id: locale.h 30794 2009-03-08 02:19:07Z neil $


 * 1) include 


 * 1) define CATCOMP_NUMBERS
 * 2) include "strings.h"

/*** Prototypes *************************************************************/ /* Main *********************************************************************/ CONST_STRPTR _(ULONG ID);      /* Get a message, as a STRPTR */
 * 1) define __(id) ((IPTR) _(id))  /* Get a message, as an IPTR */

/* Setup ********************************************************************/ VOID Locale_Initialize(VOID); VOID Locale_Deinitialize(VOID);


 * 1) endif /* _LOCALE_H_ */