'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Portions Copyright (c) 1995, 2011, Oracle and/or its affiliates.All rights reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH locale 1 "2011 年 5 月 8 日" "SunOS 5.11" "用户命令" .SH 名称 locale \- 获取特定于语言环境的信息 .SH 用法概要 .LP .nf \fBlocale\fR [\fB-a\fR | \fB-m\fR] .fi .LP .nf \fBlocale\fR [\fB-ck\fR] \fIname\fR... .fi .SH 描述 .sp .LP \fBlocale\fR 实用程序可将有关当前语言环境或所有公共语言环境的信息写入标准输出。对于本节而言,\fIpublic locale\fR 是该应用程序可访问的某个实现所提供的。 .sp .LP 不使用任何参数调用 \fBlocale\fR 时,将汇总由环境变量设置所确定的每个语言环境类别的当前语言环境。 .sp .LP 使用操作数调用时,将写入已赋予语言环境类别中的关键字的值,如下所示: .RS +4 .TP .ie t \(bu .el o 指定关键字名称将选择指定关键字和包含该关键字的类别。 .RE .RS +4 .TP .ie t \(bu .el o 指定类别名称将选择指定类别和该类别中的所有关键字。 .RE .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-a\fR\fR .ad .RS 6n .rt 写入有关所有可用的公共语言环境的信息。可用的语言环境包括 \fBPOSIX\fR,表示 POSIX 语言环境。 .RE .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .RS 6n .rt 写入所选语言环境类别的名称。当选定多个类别(例如,通过多个关键字名称或通过某个类别名称)时,\fB-c\fR 选项会提高可读性。使用或不使用 \fB-k\fR 选项均有效。 .RE .sp .ne 2 .mk .na \fB\fB-k\fR\fR .ad .RS 6n .rt 写入所选关键字的名称和值。程序实现可能会省略某些关键字的值;请参见“操作数”部分。 .RE .sp .ne 2 .mk .na \fB\fB-m\fR\fR .ad .RS 6n .rt 写入可用字符映射的名称;请参见 \fBlocaledef\fR(1)。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIname\fR\fR .ad .RS 8n .rt 语言环境类别的名称、语言环境类别中的关键字的名称或保留名称 \fBcharmap\fR。所指定的类别或关键字是为输出选择的。如果单个 \fIname\fR 同时代表当前语言环境设置中的语言环境类别名称和关键字名称,则结果是不确定的;否则,类别和关键字名称都可以指定为以任意序列排列的 \fIname\fR 操作数。 .RE .SH 示例 .LP \fB示例 1 \fR语言环境实用程序的示例 .sp .LP 在以下示例中,假设语言环境变量的设置如下所示: .sp .in +2 .nf LANG=locale_x LC_COLLATE=locale_y .fi .in -2 .sp .sp .LP 命令 \fBlocale\fR 可能会产生以下输出: .sp .in +2 .nf LANG=locale_x LC_CTYPE="locale_x" LC_NUMERIC="locale_x" LC_TIME="locale_x" LC_COLLATE=locale_y LC_MONETARY="locale_x" LC_MESSAGES="locale_x" LC_ALL= .fi .in -2 .sp .sp .LP 以下命令 .sp .in +2 .nf \fBLC_ALL=POSIX locale -ck decimal_point\fR .fi .in -2 .sp .sp .LP 将生成: .sp .in +2 .nf LC_NUMERIC decimal_point="." .fi .in -2 .sp .sp .LP 以下命令显示了应用 \fBlocale\fR 来确定用户提供的响应是否是肯定性的: .sp .in +2 .nf \fBif printf "%s\en" "$response" | /usr/xpg4/bin/grep -Eq\e "$(locale yesexpr)" then affirmative processing goes here else non-affirmative processing goes here fi\fR .fi .in -2 .sp .SH 环境变量 .sp .LP 有关 \fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR 的说明,请参见 \fBenviron\fR(5)。 .sp .LP \fBLANG\fR、\fBLC_*\fR 和 \fBNLSPATH\fR 环境变量必须指定要写出的当前语言环境。如果未指定 \fB-a\fR 选项,将使用这些环境变量。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 所有请求的信息均已找到并成功输出。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性text/locale _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBlocaledef\fR(1)、\fBattributes\fR(5)、\fBcharmap\fR(5)、\fBenviron\fR(5)、\fBlocale\fR(5)、\fBlocale_alias\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 如果已指定类别 \fBLC_CTYPE\fR 中的 \fBLC_CTYPE\fR 或关键字,则只会写出范围 \fB0x00\fR-\fB0x7f\fR 中的值。 .sp .LP 如果已指定类别 \fBLC_COLLATE\fR 中的 \fBLC_COLLATE\fR 或关键字,则不会写出任何实际值。 .sp .LP 显示在 \fBlocale -a\fR 输出中的语言环境名称仅限于标准化语言环境名称。有关可接受的和受支持的语言环境别名,请参见 \fBlocale_alias\fR(5)。