bindtextdomain 中文man頁面
NAME
bindtextdomain - 設(shè)置 包括 消息條目 的 路徑
總覽 (SYNOPSIS)
#include <libintl.h> char * bindtextdomain (const char * domainname, const char * dirname);
描述 (DESCRIPTION)
bindtextdomain 函數(shù) 的 作用 是 設(shè)置 指定消息域 里,包含 消息條目 (message catalog) 的 基本目錄 層次結(jié)構(gòu)。
一個 消息域 是 一套 可翻譯的 msgid 消息。 通常,每一個 軟件包 有 它自己的 消息域。 提出 bindtextdomain 的 需求 是因為軟件包 安裝 的 時候,并不總和 <libintl.h> 頭文件 和 libc/libintl 庫文件 的前綴保持一致.
消息條目 期望的 路徑名 是 dirname/locale/category/domainname.mo, 其中 locale 是 locale 名, 而 category 是 locale 面, 如 LC_MESSAGES.
domainname 必須 是 非空字符串。
如果 dirname 不是 NULL, 屬于 domainname 域 的消息條目 的 基本目錄 被設(shè)置為 dirname。 函數(shù) 能夠 復制 參數(shù)字符串。如果 程序 希望 調(diào)用 chdir 函數(shù), dirname 必須 是 絕對路徑名;否則 程序 無法 保證 找到 消息條目。
如果 dirname 是 NULL, 函數(shù) 返回 以前 為 domainname 域 設(shè)置的 基本目錄。
返回值 (RETURN VALUE)
如果成功, bindtextdomain 函數(shù) 返回 當前 domainname 域的 基本目錄, 如果 改變了 基本目錄, 返回 改變后的 基本目錄。 返回的 字符串 一直 有效, 直到 下一次 對 同一個 domainname 調(diào)用 bindtextdomain; 這個 字符串 不應該 被修改 或 釋放。如果 發(fā)生 內(nèi)存分配錯誤, errno 設(shè)置為 ENOMEM, 然后 返回 NULL.
錯誤 (ERRORS)
下列 錯誤 可能 發(fā)生, 包括 其它的:
- ENOMEM
- 沒有 足夠的 內(nèi)存 可用。
BUGS
返回類型 應該是 const char *, 但是 為了 避免 較早版本 ANSI C 代碼 的 警告, 返回類型 是 char *.
另見 (SEE ALSO)
gettext(3), dgettext(3), dcgettext(3), ngettext(3), dngettext(3), dcngettext(3), textdomain(3), realpath(3)
#p#
NAME
bindtextdomain - set directory containing message catalogs
SYNOPSIS
#include <libintl.h> char * bindtextdomain (const char * domainname, const char * dirname);
DESCRIPTION
The bindtextdomain function sets the base directory of the hierarchy containing message catalogs for a given message domain.
A message domain is a set of translatable msgid messages. Usually, every software package has its own message domain. The need for calling bindtextdomain arises because packages are not always installed with the same prefix as the <libintl.h> header and the libc/libintl libraries.
Message catalogs will be expected at the pathnames dirname/locale/category/domainname.mo, where locale is a locale name and category is a locale facet such as LC_MESSAGES.
domainname must be a non-empty string.
If dirname is not NULL, the base directory for message catalogs belonging to domain domainname is set to dirname. The function makes copies of the argument strings as needed. If the program wishes to call the chdir function, it is important that dirname be an absolute pathname; otherwise it cannot be guaranteed that the message catalogs will be found.
If dirname is NULL, the function returns the previously set base directory for domain domainname.
RETURN VALUE
If successful, the bindtextdomain function returns the current base directory for domain domainname, after possibly changing it. The resulting string is valid until the next bindtextdomain call for the same domainname and must not be modified or freed. If a memory allocation failure occurs, it sets errno to ENOMEM and returns NULL.
ERRORS
The following error can occur, among others:
- ENOMEM
- Not enough memory available.
BUGS
The return type ought to be const char *, but is char * to avoid warnings in C code predating ANSI C.
SEE ALSO
gettext(3), dgettext(3), dcgettext(3), ngettext(3), dngettext(3), dcngettext(3), textdomain(3), realpath(3)