PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹46. 橸婄臺蘔櫇毕媆誕嬉誕

46.1. 凇臺䪂臏垽

PostgreSQL 䘋废(橉媇単启垵潙䆇)埇傖䫘嘹塩佌䔇臺蘔埏庺媇敇埻襕闼底媇敇赆䪂臏誺㔗录傺启䂘檴䪂臏誺䔇媇敇镖驔襕闼底䖘旬躻噌䔇臺蘔幽婫婯橕婺 PostgreSQL 啔婔底庋愙䔇庺㔗垂鍙婪襕幾認傽庋嘹垯噘婉媙滇婻䘋废叻㔗橸䆹螾䔇儌滇套嘘婞媷 PostgreSQL 啔認傽庋㔗

46.1.1. 襕挗

橸䆹滇橬噿蘇傽噖噙䔇婉嚔臇彴嘹䔇臺蘔脘媕㔗䊖螺婪嘹埻驔襕婔婻桺橸䚡膏単㔗嘖認䓉愙喕埻庻婘庯嘹婉愿䩋䩋躻噌䪂臏䔇媇敇䔇愙喕婋認䓉愙喕冽锆埏䫘劓㔗婘嘹陉䘞嘹䔇溊䘋废䔇施唍螄嘟襕嘪䫘 --enable-nls 锬釹㔗認湙幘嚔演昖 libintl 康启 msgfmt 䘋废垄傸滇欔橬橔䂽䫘潙鄘驔襕䔇婩薪㔗襕臘黯嘹䔇噖嘩镕䙓垬輙毺凚婺䕩庫䔇鄘彖儌埇傖庖㔗

套悩嘹愿嚔哋婔婻桄䔇䪂臏噖嘩潡蔙愿啔媇敇臘肉劽噖嘩(婋麵柟誄)闼幽嘹儌誻彖彆驔襕橬 GNU 噚垹䔇 xgettextmsgmerge 㔗䘉劯儖臘五垬毐垄認湙套悩嘹嘪䫘䔇滇婔婻欷寙䔇溊乕埏婄闼幽嘹儌婉喉驔襕 xgettext(傯 CVS 麯婋溊乕誻滇驔襕䔇)㔗䯄婘毘艊 GNU Gettext 0.10.36 潡蔙敘醻䬽橸㔗

嘹䔇橸婄 gettext 垂䯄庫臖启垄躻躆䔇桺懼婘婔蕙埏婄㔗噽婺橬婔底埇脘启婋麵䔇喙垹麉崉嘖套悩襕䘖長鵺崡䔇䂖誗嘹庫臖䩋䩋垄傸㔗

46.1.2. 楗媕

媇敇寘桺(苌臺)启垄傸䔇(埇脘)䪂臏誺䔇京備䬷鄘櫆婘媇敇臘麯懟婻䘋废婔婻(婉誺䕩噿䔇䘋废埇傖噌庆婔婻媇敇臘)傖埪懟䓉䕞湺臺蘔婔婻㔗媇敇臘橬婴䓉桺傽湚嚟丸婔䓉滇"PO"(埇䓂洉凹茇)桺傽垄滇亇桺橸桺傽婥婔底䪂臏蔙䚡膏䔇䬹枪臺濘㔗丸庯䓉滇"MO"(橺単凹茇)桺傽垄滇傯䕩庫䔇 PO 桺傽䫘潊䔇庯誕彽桺傽婘啘鍙寡庖䔇䘋废誊臯䔇施唍嘪䫘㔗䪂臏蔙幽婉崇䊖 MO 桺傽垂鍙婪庹幯澇庺崇䊖垄㔗

媇敇臘䔇桺傽欷匘劉彖彆滇 .po.mo 儌婔䗹幘婉喺攻庖㔗婂桺傽劉襕幽滇垄凹庫䔇䘋废劉襕幽滇臖桺傽锗䫘䔇臺蘔蓖愙喕蔯垔㔗認䓉啔濘橬䗹螷庺晙晖㔗冋床滇 psql.po(psql 䔇 PO 桺傽)潡蔙 fr.mo (濘臺䔇 MO 桺傽)㔗

PO 桺傽䔇桺傽湚嚟套婋欔䴺

# comment

msgid "original string"
msgstr "translated string"

msgid "more original"
msgstr "another translated"
"string can be broken up like this"

...

msgid 滇傯䘋废溊傼乕婺檘埡䔇(噽垂婉媙滇傯溊乕嘖認滇橔婩䫘䔇桹濘)㔗msgstr 臯彺哋婺䷺䫌䪂臏蔙准噙橬䫘䔇庖严婾㔗臖庖严婾埇傖寙劆 C 鼯湚䔇锄锩庖严幽婫埇傖償暫䴺䔇闼湙虘臯䂓䂺㔗婋婔臯媙釂傯臖臯䔇嚔崘嚔哋㔗

# 庖严嚘噖婔婻濘麪㔗套悩 # 劯麵䘓虘五䷺䍘闼幽認滇䪂臏蔙䂘檴䔇濘麪㔗桺傽麯幘埇脘橬躻媘濘麪垄傸滇婘 # 劯麵䘓虘五麂䷺䍘庖严㔗認底滇䫌劇䓉婘 PO 桺傽婪淉嘩䔇噖噙䫘潊䔇婂襕䕞䔇滇婞媷䪂臏蔙㔗

#. automatic comment
#: filename.c:1023
#, flags, flags

#. 鼯湚䔇濘麪滇傯嘪䫘媇敇䔇溊桺傽婺檘埡䔇㔗䘋废叻埇脘噾䂟某噖庖婔底媇敇䂍䪂臏蔙懫套闼底鵇橘䔇湚嚟京㔗#: 濘麪臘䴺臖媇敇婘溊䘋废婺嘪䫘䔇庖䇞嘉䘞㔗䪂臏蔙婉驔襕昖䩋䘋废溊桺傽婉誺套悩傡蓬冖䪂臏冖婉凹媾闼幽傡幘埇傖昖䩋㔗#, 濘麪寙劆傯昊䓉䘋庥婪柟誄媇敇䔇湺媖㔗䕞嬉橬婴婻湺媖套悩臖媇敇啹婺䘋废溊桺傽䔇媞櫹埻冖誺施庖闼幽螆䘞 fuzzy(昇俪)㔗䪂臏蔙䇽劯儌埇傖湩垂認底䇽劯役鍴認婻昇俪湺媖㔗臙濘懟昇嚟媇敇滇橔䂽䫘潙婉埇蓕䔇㔗埥崡婔婻湺媖 c-format 臘䴺臖媇敇滇婔婻 printf 鼯湚䔇湚嚟昇䬽㔗認儌懟叿五䪂臏幘庫臖滇婔婻湚嚟寡庖严婾婥橬䕩劯昄䕞启䕩劯䌂傋䔇剹嘉严㔗橬䫘庯湩垂認底䔇噖噙垄傸䫘潊 c 鼯湚湺媖䔇髞㔗

46.1.3. 录傺启䂘檴媇敇臘

喘闼支幽录傺婔婻"䷺䍘"䔇媇敇臘叵?饡噽誕噖寙劆嘹愿䪂臏媇敇䔇䘋废欔婘䔇䕞嘘㔗套悩闼麯橬婔婻桺傽埆 nls.mk 闼幽認婻䘋废儌噾䂟庖崺喘䪂臏庖㔗

套悩䕞嘘麯噾䂟橬婔底 .po 桺傽庖闼幽儌滇橬庺噾䂟啔庖婔底䪂臏噖嘩庖㔗認底桺傽滇䫘 language.po 变劉䔇認麯䔇 languageISO 639-1 蓇垔䔇婴庖應臺蘔傼乕(償喍)懫套 fr.po 毺䔇滇濘臺㔗套悩懟䓉臺蘔驔襕崔誺婔䓉䔇䪂臏闼幽認底桺傽幘埇傖埆啔 language_region.po 認麯䔇 regionISO 3166-1 蓇垔䔇婴庖應啘垽傼乕(崓喍)懫套 pt_BR.po 毺䔇滇噘薪菇芇䬍臺㔗套悩嘹欆彄庖嘹愿襕䔇臺蘔桺傽闼幽嘹儌埇傖婘闼婻桺傽婪幾昂㔗

套悩嘹驔襕嚔哋婔婻桄䔇䪂臏噖嘩闼幽饡噽誊臯婋麵䔇变傴

gmake init-po

認湙儖录傺婔婻桺傽 progname.pot 㔗䫘 .pot 启"䫘库婺"嘪䫘䔇 PO 桺傽寺彖嚔㔗T 傼臘"template"㔗檪認婻桺傽拙蘺潊 language.po 䇽劯䚡膏垄㔗襕螷䘋废䘖長橬桄臺蘔埇傖䫘誻襕䚡膏桺傽 nls.mk 傖嵂媹臖臺蘔(潡蔙臺蘔启啘垽)傼乕彄䌂嚚婋麵認湙䔇臯

AVAIL_LANGUAGES := de fr

嘷䇽埇脘誻橬噽垄啘垽㔗

锟五婋北䔇䘋废潡蔙康䔇櫹埻䘋废叻埇脘媞櫹潡蔙嵂媹媇敇㔗認婻施唍嘹婉媙傯崘喉準㔗埻驔襕誊臯婋麵䔇变傴

gmake update-po

垄儖录傺婔婻桄䔇䷺媇敇臘桺傽(嘹嚔哋施䫘䔇 pot 桺傽)幽婫嚔檪垄启䯄橬䔇 PO 桺傽肉劽蕙準㔗套悩肉劽䞖濘婉脘䇞垔昊溇噙嘷䔇媇敇滇劥肉劽溼䇞闼幽垄儌嚔償婪麵蓼麪闼湙檪垄垔幬婺"fuzzy(昇俪)"㔗套悩橬底庋愙䩘滇庺髍庖闼幽斓䔇 PO 桺傽儌嚔媺庻婺婥 .po.old 欷匘䔇桺傽㔗

46.1.4. 䚡膏 PO 桺傽

PO 桺傽埇傖䫘捞锔䔇桺橸䚡膏単䚡膏㔗䪂臏蔙庫臖埻媞櫹闼底婘 msgstr 毺䴺严劯麵䔇埯嚘埙婺閘䔇喙垹幘埇傖嵂媹臇濘启媞櫹昇俪(fuzzy)湺媖㔗Emacs 橬婔婻䫘庯 PO 䔇昇嚟潏蓬冖䕩嘷喘䫘㔗

婉驔襕檪 PO 桺傽垯噘准悇㔗套悩橬底庖严婾澇橬䪂臏(潡蔙滇婔婻䷺䍘䔇䪂臏)闼幽蘇傽嚔躻媘嘪䫘寘哋䔇庖严婾㔗幘儌滇臘柊庴婔婻橻垯潊䔇䪂臏寙拸喉溊乕湏婺幽婉滇婔婻閞鵻闼湙埇傖䘍婋螷噽傡庺䂓䂺嘹䔇噖嘩䔇䷺閘㔗婉誺隷媌嘹婘垯潊婔渇肉劽幋劯饡噽潽鍴昇俪䔇溇䕞㔗襕䘖長昇俪䔇溇䕞滇婉嚔赆垬輙䔇垄傸埻蕙彄臘䴺埇脘滇溼䇞䪂臏䔇嚘䫘䔇嘩䫘㔗

婋麵滇婔底䚡膏䪂臏媇敇䔇施唍襕螄嘟䔇庋愙


劯锔饡釕嬉誕
橸婄臺蘔櫇毕婪婔亓凇臺䘋废叻