新的 genmsg 公用程式可以與 catgets() 函式家族配合使用,以建立國際化來源訊息目錄。這個公用程式會檢查 catgets 中函式呼叫的來源程式檔案,並從尋獲的資訊建立來源訊息目錄。例如:
% cat example.c ... /* NOTE: %s is a file name */ printf(catgets(catd, 5, 1, "%s cannot be opened.")); /* NOTE: "Read" is a past participle, not a present tense verb */ printf(catgets(catd, 5, 1, "Read")); ... % genmsg -c NOTE example.c The following file(s) have been created. new msg file = "example.c.msg" % cat example.c.msg $quote " $set 5 1 "%s cannot be opened" /* NOTE: %s is a file name */ 2 "Read" /* NOTE: "Read" is a past participle, not a present tense verb */
在上述的範例中,genmsg 會在來源檔案上執行 example.c,並產生了名為 example.c.msg 的來源訊息目錄。-c 選項 (包含引數 NOTE) 會使得 genmsg 在目錄中包含註釋。若是來源程式中的註釋包含指定的字串,則下一個從 catgets 呼叫中所擷取的字串之後的訊息目錄便會出現註釋。
您可以使用 genmsg,自動為訊息集合中的訊息計數。
若要產生格式化的訊息目錄檔,請使用 gencat(1) 公用程式。
關於可攜式訊息檔案 (.po 檔案) 的訊息擷取公用程式以及如何從 .po 檔案產生訊息物件檔案 (.mo 檔案) 的資訊。