Aros/开发者/文档/库/语言环境
这里有一个全局环境变量(Language),它保存着当前活动的语言。
您可以通过在 Shell 中键入“getenv language”(不带引号)来检查它。或者它可以在脚本中用作变量 $Language。
它也可以通过编程使用 OpenLocale() 函数完成(使用 NULL 作为参数以返回结构 Locale 中的当前语言环境信息)。
locale.library 为我们提供了本地化应用程序的工具。本地化字符串存储在单独的语言目录文件(在 Catalogs 目录下)中。AROS 开发环境宏可以构建所需的文件。本文档为您提供了一个工作流程,用于本地化应用程序或本地化现有应用程序,或为现有本地化应用程序创建目录文件。
对于系统支持的每种语言,系统都有一个 LOCALE:Languages/ 文件
LOCALE:Languages/klingon.language
系统翻译位于 LOCALE:Catalogs/ language 目录中
LOCALE:Catalogs/klingon/
每个应用程序都需要其适当的 Catalogs 目录
my_app/Catalogs/
翻译文件位于 language 目录中
my_app/Catalogs/klingon/my_app.catalog
每个支持本地化的应用程序都有自己的 catalogs 目录
AROS/Contrib/my_app/catalogs
字符串最初存储在目录描述文件中
AROS/Contrib/my_app/catalogs/my_app.cd
This file is structured as: ; MSG_TITLE (//) My Application ; MSG_MY_MESSAGE (//) My application message ; ...
翻译存储在目录翻译文件中
AROS/Contrib/my_app/catalogs/klingon.ct
结构如下
## version $VER: my_app.catalog 1.0 (23.05.2004) ## language klingon ## codeset 0 ; MSG_TITLE tlhIngan maH ; MSG_MY_MESSAGE Sujatlh 'e' yImev ; ...
目录构建文件
本地化由以下提供
AROS/Contrib/my_app/locale.c
AROS/contrib/my_app/locale.h
应用程序:_(MSG_MY_TITLE)
作为 STRPTR。
或使用:__(MSG_MY_MESSAGE)
作为 IPTR(1) 应用程序源文件
在 AROS/Contrib/my_app/my_app.c 中,使用以下命令初始化语言环境
...
#include "locale.h"
main()
{
...
使用 .cd 文件中的字符串名称。例如,在 Zune 应用程序中:MUIA_Application_Title, __(MSG_TITLE), ... } 应用程序构建文件
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: #MM- my_app: \ ... #MM my_app-catalogs Build the locale AROS/ 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.
AROS Metamake 使用其构建文件(存在于以下位置)构建所需文件
AROS/Contrib/my_app/catalogs/mmakefile.src
# Copyright © 2004, The AROS Development Team. All rights reserved.
# $Id: mmakefile.src,v 1.2 2004/02/19 22:05:38 john doe Exp $
include $(TOP)/config/make.cfg
%build_catalogs mmake=my_app-catalogs \
name=My_App \
subdir= \
dir=$(AROSDIR)/Extras/My_App/Catalogs
Application directory
AROS/Contrib/my_app/
FlexCat 是一种用于创建 Amiga 本地化目录以及源文件和头文件的工具,这些文件来自于目录描述。
AROS/tools 中的版本是 2.4,开发人员的 readme 文件说明将其视为免费软件(包含源代码),但不要进行分支。历史记录文件告诉我们,2.4 版来自 1999 年 11 月 28 日。文档中提到的并非所有网站都仍然存在,但 flexcat 确实支持 2.4 版,并且没有提到进一步的开发。移植是否算分支?如果没有,那么一个以前的移植是否算分支(例如,仅仅因为 AROS 成为 68k)?如果最初只有一个移植,但其他人做了另一个移植 - 谁是分支者?也许作者只是太不精确了,应该提供分支的定义……
1 AROS 项目的戳记是 2009 年 3 月 7 日,因此过去十年中 AROS 版本可能发生了变化。
2 Aminet 上的最后一个版本是 2010 年 6 月 29 日发布的 2.7 版,由 项目 发布,该项目声称版权始于 2002 年。
原始主页 已过时。它现在是一个使用 GPL 许可的 产品,在这里维护。当然,2.7 发行版不包含源代码,因为该项目是开源的,并且 源代码 对所有人开放。发行版存档仅包含所有支持平台的二进制文件。
- 从 FlexCat 的稳定版本更新 AROS 中的源代码
- 使其再次可构建,也许我可以从之前的提交中合并提交。
- C_h_orig.sd 在当前的 FlexCat 中不再可用。找到一个可以与 AROS 构建系统一起使用的替换。
- 将 AROS 的所有修复程序带回到 FlexCat 的当前主干。通过加入 Sourceforge 上的项目或将其发送给维护人员。
如果您愿意加入团队并将更改提交到 sourceforge.net 上的 SVN 存储库,我们将不胜感激。只需询问 Jens Langer(damato#light-speed.de)将您添加到开发者列表中。
可选:等待“vendor”分支在 AROS 存储库中可用,并使用该分支。
/*
Copyright © 1995-2004, The AROS Development Team. All rights reserved.
$Id: locale.c 30794 2009-03-08 02:19:07Z neil $
*/
#include <exec/types.h>
#include <proto/locale.h>
#define CATCOMP_ARRAY
#include "strings.h"
#define CATALOG_NAME "AiRcOS.catalog"
#define CATALOG_VERSION 0
/*** Variables **************************************************************/
struct Catalog *catalog;
/*** Functions **************************************************************/
/* Main *********************************************************************/
CONST_STRPTR _(ULONG id)
{
if (LocaleBase != NULL && catalog != NULL)
{
return GetCatalogStr(catalog, id, CatCompArray[id].cca_Str);
}
else
{
return CatCompArray[id].cca_Str;
}
}
/* Setup ********************************************************************/
VOID Locale_Initialize(VOID)
{
if (LocaleBase != NULL)
{
catalog = OpenCatalog
(
NULL, CATALOG_NAME, OC_Version, CATALOG_VERSION, TAG_DONE
);
}
else
{
catalog = NULL;
}
}
VOID Locale_Deinitialize(VOID)
{
if(LocaleBase != NULL && catalog != NULL) CloseCatalog(catalog);
}
#ifndef _LOCALE_H_ #define _LOCALE_H_ /* Copyright © 2003-2004, The AROS Development Team. All rights reserved. $Id: locale.h 30794 2009-03-08 02:19:07Z neil $ */ #include <exec/types.h> #define CATCOMP_NUMBERS #include "strings.h" /*** Prototypes *************************************************************/ /* Main *********************************************************************/ CONST_STRPTR _(ULONG ID); /* Get a message, as a STRPTR */ #define __(id) ((IPTR) _(id)) /* Get a message, as an IPTR */ /* Setup ********************************************************************/ VOID Locale_Initialize(VOID); VOID Locale_Deinitialize(VOID); #endif /* _LOCALE_H_ */
/* constants for GetLocaleStr() */ #define DAY_1 1 /* Sunday */ #define DAY_2 2 /* Monday */ #define DAY_3 3 /* Tuesday */ #define DAY_4 4 /* Wednesday */ #define DAY_5 5 /* Thursday */ #define DAY_6 6 /* Friday */ #define DAY_7 7 /* Saturday */ #define ABDAY_1 8 /* Sun */ #define ABDAY_2 9 /* Mon */ #define ABDAY_3 10 /* Tue */ #define ABDAY_4 11 /* Wed */ #define ABDAY_5 12 /* Thu */ #define ABDAY_6 13 /* Fri */ #define ABDAY_7 14 /* Sat */ #define MON_1 15 /* January */ #define MON_2 16 /* February */ #define MON_3 17 /* March */ #define MON_4 18 /* April */ #define MON_5 19 /* May */ #define MON_6 20 /* June */ #define MON_7 21 /* July */ #define MON_8 22 /* August */ #define MON_9 23 /* September */ #define MON_10 24 /* October */ #define MON_11 25 /* November */ #define MON_12 26 /* December */ #define ABMON_1 27 /* Jan */ #define ABMON_2 28 /* Feb */ #define ABMON_3 29 /* Mar */ #define ABMON_4 30 /* Apr */ #define ABMON_5 31 /* May */ #define ABMON_6 32 /* Jun */ #define ABMON_7 33 /* Jul */ #define ABMON_8 34 /* Aug */ #define ABMON_9 35 /* Sep */ #define ABMON_10 36 /* Oct */ #define ABMON_11 37 /* Nov */ #define ABMON_12 38 /* Dec */ #define YESSTR 39 /* affirmative response for yes/no queries */ #define NOSTR 40 /* negative response for yes/no queries */ #define AM_STR 41 /* AM */ #define PM_STR 42 /* PM */ #define SOFTHYPHEN 43 /* soft hyphenation */ #define HARDHYPHEN 44 /* hard hyphenation */ #define OPENQUOTE 45 /* start of quoted block */ #define CLOSEQUOTE 46 /* end of quoted block */ #define YESTERDAYSTR 47 /* Yesterday */ #define TODAYSTR 48 /* Today */ #define TOMORROWSTR 49 /* Tomorrow */ #define FUTURESTR 50 /* Future */ #define MAXSTRMSG 51 /* current number of defined strings */ /* This structure must only be allocated by locale.library and is READ-ONLY! */ struct Locale { STRPTR loc_LocaleName; /* locale's name */ STRPTR loc_LanguageName; /* language of this locale */ STRPTR loc_PrefLanguages[10]; /* preferred languages */ ULONG loc_Flags; /* always 0 for now */ ULONG loc_CodeSet; /* always 0 for now */ ULONG loc_CountryCode; /* user's country code */ ULONG loc_TelephoneCode; /* country's telephone code */ LONG loc_GMTOffset; /* minutes from GMT */ UBYTE loc_MeasuringSystem; /* what measuring system? */ UBYTE loc_CalendarType; /* what calendar type? */ UBYTE loc_Reserved0[2]; STRPTR loc_DateTimeFormat; /* regular date & time format */ STRPTR loc_DateFormat; /* date format by itself */ STRPTR loc_TimeFormat; /* time format by itself */ STRPTR loc_ShortDateTimeFormat; /* short date & time format */ STRPTR loc_ShortDateFormat; /* short date format by itself */ STRPTR loc_ShortTimeFormat; /* short time format by itself */ /* for numeric values */ STRPTR loc_DecimalPoint; /* character before the decimals */ STRPTR loc_GroupSeparator; /* separates groups of digits */ STRPTR loc_FracGroupSeparator; /* separates groups of digits */ UBYTE *loc_Grouping; /* size of each group */ UBYTE *loc_FracGrouping; /* size of each group */ /* for monetary values */ STRPTR loc_MonDecimalPoint; STRPTR loc_MonGroupSeparator; STRPTR loc_MonFracGroupSeparator; UBYTE *loc_MonGrouping; UBYTE *loc_MonFracGrouping; UBYTE loc_MonFracDigits; /* digits after the decimal point */ UBYTE loc_MonIntFracDigits; /* for international representation */ UBYTE loc_Reserved1[2]; /* for currency symbols */ STRPTR loc_MonCS; /* currency symbol */ STRPTR loc_MonSmallCS; /* symbol for small amounts */ STRPTR loc_MonIntCS; /* international (ISO 4217) code */ /* for positive monetary values */ STRPTR loc_MonPositiveSign; /* indicate positive money value */ UBYTE loc_MonPositiveSpaceSep; /* determine if separated by space */ UBYTE loc_MonPositiveSignPos; /* position of positive sign */ UBYTE loc_MonPositiveCSPos; /* position of currency symbol */ UBYTE loc_Reserved2; /* for negative monetary values */ STRPTR loc_MonNegativeSign; /* indicate negative money value */ UBYTE loc_MonNegativeSpaceSep; /* determine if separated by space */ UBYTE loc_MonNegativeSignPos; /* position of negative sign */ UBYTE loc_MonNegativeCSPos; /* position of currency symbol */ UBYTE loc_Reserved3; }; /* constants for Locale.loc_MeasuringSystem */ #define MS_ISO 0 /* international metric system */ #define MS_AMERICAN 1 /* american system */ #define MS_IMPERIAL 2 /* imperial system */ #define MS_BRITISH 3 /* british system */ /* constants for Locale.loc_CalendarType */ #define CT_7SUN 0 /* 7 days a week, Sunday is the first day */ #define CT_7MON 1 /* 7 days a week, Monday is the first day */ #define CT_7TUE 2 /* 7 days a week, Tuesday is the first day */ #define CT_7WED 3 /* 7 days a week, Wednesday is the first day */ #define CT_7THU 4 /* 7 days a week, Thursday is the first day */ #define CT_7FRI 5 /* 7 days a week, Friday is the first day */ #define CT_7SAT 6 /* 7 days a week, Saturday is the first day */ /* constants for Locale.loc_MonPositiveSpaceSep and Locale.loc_MonNegativeSpaceSep */ #define SS_NOSPACE 0 /* cur. symbol is NOT separated from value with a space */ #define SS_SPACE 1 /* cur. symbol IS separated from value with a space */ /* constants for Locale.loc_MonPositiveSignPos and Locale.loc_MonNegativeSignPos */ #define SP_PARENS 0 /* () surround the quantity and currency_symbol */ #define SP_PREC_ALL 1 /* sign string comes before amount and symbol */ #define SP_SUCC_ALL 2 /* sign string comes after amount and symbol */ #define SP_PREC_CURR 3 /* sign string comes right before currency symbol */ #define SP_SUCC_CURR 4 /* sign string comes right after currency symbol */ /* constants for Locale.loc_MonPositiveCSPos and Locale.loc_MonNegativeCSPos */ #define CSP_PRECEDES 0 /* currency symbol comes before value */ #define CSP_SUCCEEDS 1 /* currency symbol comes after value */ /* elements of the byte arrays pointed to by: * Locale.loc_Grouping * Locale.loc_FracGrouping * Locale.loc_MonGrouping * Locale.loc_MonFracGrouping * are interpreted as follows: * * 255 indicates that no further grouping is to be performed * 0 indicates that the previous element is to be repeatedly used for the remainder of the digits * <other> the number of digits that comprises the current group */ /* This structure must only be allocated by locale.library and is READ-ONLY! */ struct Catalog { struct Node cat_Link; /* for internal linkage */ UWORD cat_Pad; /* to longword align */ STRPTR cat_Language; /* language of the catalog */ ULONG cat_CodeSet; /* currently always 0 */ UWORD cat_Version; /* version of the catalog */ UWORD cat_Revision; /* revision of the catalog */ };
void CloseCatalog(struct Catalog *catalog) (A0) void CloseLocale(struct Locale *locale) (A0) ULONG ConvToLower(const struct Locale *locale, ULONG character) (A0, D0) ULONG ConvToUpper(const struct Locale *locale, ULONG character) (A0, D0) void FormatDate(const struct Locale *locale, CONST_STRPTR formatString, const struct DateStamp *date, const struct Hook *hook) (A0, A1, A2, A3) APTR FormatString(const struct Locale *locale, CONST_STRPTR fmtTemplate, CONST_APTR dataStream, const struct Hook *putCharFunc) (A0, A1, A2, A3) CONST_STRPTR GetCatalogStr(const struct Catalog *catalog, ULONG stringNum, CONST_STRPTR defaultString) (A0, D0, A1) CONST_STRPTR GetLocaleStr(const struct Locale *locale, ULONG stringNum) (A0, D0) ULONG IsAlNum(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsAlpha(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsCntrl(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsDigit(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsGraph(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsLower(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsPrint(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsPunct(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsSpace(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsUpper(const struct Locale *locale, ULONG character) (A0, D0) ULONG IsXDigit(const struct Locale *locale, ULONG character) (A0, D0) struct Catalog *OpenCatalogA(const struct Locale *locale, CONST_STRPTR name, const struct TagItem *tags) (A0, A1, A2) struct Locale *OpenLocale(CONST_STRPTR name) (A0) BOOL ParseDate(struct Locale *locale, struct DateStamp *date, CONST_STRPTR fmtTemplate, struct Hook *getCharFunc) (A0, A1, A2, A3) struct Locale *LocalePrefsUpdate(struct Locale *locale) (A0) ULONG StrConvert(const struct Locale *locale, CONST_STRPTR string, APTR buffer, ULONG bufferSize, ULONG type) (A0, A1, A2, D0, D1) LONG StrnCmp(const struct Locale *locale, CONST_STRPTR string1, CONST_STRPTR string2, LONG length, ULONG type) (A0, A1, A2, D0, D1) private APTR LocRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc, APTR PutChData) (A0, A1, A2, A3) LONG LocStrnicmp(CONST_STRPTR string1, CONST_STRPTR string2, LONG length) (A0, A1, D0) LONG LocStricmp(CONST_STRPTR string1, CONST_STRPTR string2) (A0, A1) ULONG LocToLower(ULONG character) (D0) ULONG LocToUpper(ULONG character) (D0) LONG LocDateToStr(struct DateTime *datetime) (D1) LONG LocStrToDate(struct DateTime *datetime) (D1) CONST_STRPTR LocDosGetLocalizedString(LONG stringNum) (D1)