📄 rules.html
字号:
src="rules.files/bullets_dev2.gif" width=18><FONT
face="Geneva, Arial Narrow, Helvetica" size=2><B>Members
Only</B></FONT></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD><FONT face="ARIAL, HELVETICA" size=2><A
href="https://toolbox.sgi.com/toolbox">Developer's</A><BR> <A
href="https://toolbox.sgi.com/toolbox">Toolbox</A><IMG
align=absBottom alt=* height=15 src="rules.files/locko.gif"
width=27><BR><A
href="https://www.sgi.com/developers/devnews/index.html">Developer
News</A><IMG align=absBottom alt=* height=15
src="rules.files/locks.gif" width=27><BR><A
href="https://www.sgi.com/developers/devedge/index.html">DevEdge Email</A><IMG
align=absBottom alt=* height=15 src="rules.files/locko.gif"
width=27><BR><A
href="https://toolbox.sgi.com/toolbox/documents/KnowledgeBase/">KnowledgeBase</A><IMG
align=absBottom alt=* height=15 src="rules.files/locko.gif"
width=27><BR><A
href="http://www.sgi.com/developers/library/doc.html">Developer
Consulting</A> </FONT><BR> </TD></TR>
<TR>
<TD></TD>
<TD colSpan=2><IMG alt="" height=10
src="rules.files/bullets_dev2.gif" width=18><FONT
face="Geneva, Arial Narrow, Helvetica" size=2><B>Helpful
Resources</B></FONT></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD><FONT face="ARIAL, HELVETICA" size=2><A
href="http://www.sgi.com/developers/library/resource.html">Useful
Links</A><BR><A href="http://www.sgi.com/fun/">Freeware</A><BR><A
href="http://www.sgi.com/developers/library/resources/vst.html">Video
Server Toolkit</A><BR><A
href="http://www.sgi.com/developers/library/resources/y2k.html">Year
2000</A><BR><A href="http://techpubs.sgi.com/">Technical
Publications</A><BR> <A
href="http://techpubs.sgi.com/">Library</A><BR><A
href="http://www.sgi.com/developers/library/resources/asc.html">Application
Solution</A><BR> <A
href="http://www.sgi.com/developers/library/resources/asc.html">Center</A>
</FONT><BR> </TD></TR>
<TR>
<TD></TD>
<TD colSpan=2><IMG alt="" height=10
src="rules.files/bullets_dev2.gif" width=18><FONT
face="Geneva, Arial Narrow, Helvetica"
size=2><B>Localization</B></FONT></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD><FONT face="ARIAL, HELVETICA" size=2><A
href="http://www.sgi.com/developers/library/local/faq.html">Localization
FAQ</A> </FONT></TD></TR>
<TR>
<TD></TD>
<TD colSpan=2><IMG alt=* height=10
src="rules.files/nav-bullet3.jpeg" width=13> <FONT color=#207575
face="ARIAL, HELVETICA" size=2><B>Programming Rules</B></FONT></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD><FONT face="ARIAL, HELVETICA" size=2><A
href="http://www.sgi.com/developers/library/local/code.html">Example
Code</A><BR><A
href="http://www.sgi.com/developers/library/local/glossary.html">Glossaries</A>
</FONT><BR> </TD></TR>
<TR>
<TD></TD>
<TD colSpan=2><IMG alt="" height=10
src="rules.files/bullets_dev2.gif" width=18><FONT
face="Geneva, Arial Narrow, Helvetica"
size=2><B>Archives</B></FONT></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD><FONT face="ARIAL, HELVETICA" size=2><A
href="https://www.sgi.com/developers/devnews/archives.html">Developer
News</A><IMG align=absBottom alt=* height=15
src="rules.files/lock.gif" width=27><BR><A
href="https://www.sgi.com/developers/devedge/archives.html">DevEdge</A><IMG
align=absBottom alt=* height=15 src="rules.files/lock.gif"
width=27><BR><A href="http://www.sgi.com/developers/nibs/">What's
New</A><BR><A href="http://www.sgi.com/developers/feature/">Feature
Stories</A> </FONT></TD></TR>
<TR>
<TD></TD>
<TD colSpan=2> <BR><IMG alt=image height=2
src="rules.files/dot_clear.gif" width=140>
<BR></TD></TR></TBODY></TABLE></TD>
<TD><IMG height=1 src="rules.files/dot_clear.gif" width=35></TD>
<TD vAlign=top>
<P><!-- Start Content --><FONT face="ARIAL NARROW, HELVETICA"
size=5><B>Programming Rules</B></FONT>
<P><FONT face="ARIAL, HELVETICA" size=4><B>I18N Essentials - Programming
Tips</B></FONT>
<P><FONT face="ARIAL, HELVETICA"><B>Tip 1: Call a function to set language
(locale) at the beginning of each program.</B></FONT>
<P>Call a <CODE>setlocale() </CODE>function for non-Xt/Motif programs.
Because it affects sensitive functions, <CODE>setlocale()</CODE> should
usually be called at the beginning of each program, but it can be called
whenever necessary. </P>
<P><FONT size=+0>Call <CODE>XtSetLanguageProc() </CODE>for Xt/Motif
programs. <CODE>XtSetLanguageProc() </CODE>must be called before Xt
initialization, because it does NOT set a locale; it just registers a
default language procedure which calls <CODE>setlocale() </CODE>(and other
functions). Xt only calls the procedure specified for
<CODE>XtSetLanguageProc()</CODE> when it is initialized, so calls after Xt
is set up have no effect. It's probably better just to call
<CODE>XtSetLanguageProc()</CODE> at the beginning of
main().</FONT><BR><FONT size=+0></FONT></P>
<P></P><FONT face="ARIAL, HELVETICA"><B>Tip 2: Do not hard-code messages,
labels, font names or most layout values. </FONT></B>
<P><UI></P>
<UL>
<LI><FONT size=+0>Get messages from <U>message catalog files</U> for
non-X based programs. Use <CODE>catgets() </CODE>functions. </FONT>
<P></P>
<LI><FONT size=+0>Get messages, labels, font names and most layout
values from <U>resource files</U> (or message catalog files) for X based
programs. You can also define your own resources and use them. ViewKit
has resource handling methods. </FONT></UI><FONT
color=#000000></FONT></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 3:
Use font sets instead of fonts.</B> </FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Some Asian languages need several fonts. Fonts should
be handled as font sets. </FONT><BR><FONT size=+0></FONT>
<LI><FONT size=+0>If you use Xlib functions, use <CODE>XCreateFontSet()
</CODE>function instead of <CODE>XLoadQueryFont() </CODE>function, for
font set. </FONT><BR><FONT size=+0></FONT>
<LI><FONT size=+0>If you use Motif functions and </FONT>need to create
font list in your program, use functions such as XmFontListEntryLoad(),
XmFontListEntryCreate(), XmFontListAppendEntry().</UI><FONT
color=#000000> </FONT></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 4: Do
not use special characters for widget names on Xt/Motif
programs.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>All widgets should have names because the use of NULL
as a widget name makes it impossible to identify widgets for
localization. Widget names should contain only ASCII alphanumeric
characters and underbar; it is difficult or impossible to localize
widgets whose names contain whitespace, punctuation or special
characters such as '*', '.', ':' and '?' </FONT></LI></UL>
<P></P>
<UL>
<LI><FONT size=+0>One common practice causes particular problems: naming
a widget using its label string often leads to widget names that are
difficult to use, because labels sometimes contain special characters.
</FONT></UI></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 5: Do
not fix widget arrangements and sizes of label, button, text
widgets.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Length of messages or labels may change depending on
the language. Do not adjust and fix a layout or sizes of widgets just
for English. </FONT>
<P></P>
<LI><FONT size=+0>Layout should change automatically based on language
(locale). If it is difficult and time-consuming to determine the sizes
for each widget manually, you need to define the sizes in resource
files. </FONT>
<P></P>
<LI><FONT size=+0>Because font width varies among languages, the number
of columns of text (fields) for a widget can vary by as much as a factor
of two. Therefore, this size should be adjusted automatically based on
layout, or changed by values in a resource file. Do not hard-code
it.</FONT>
<P></P>
<LI><FONT size=+0>Using the Form widget is one relatively easy (and
recommended way) to automatically adjust the layout of primitive
widgets. Define values for ATTACH_* resources explicitly and correctly
or the layout will be broken. </FONT></UI><FONT size=+0></FONT></LI></UL>
<P></P><FONT face="ARIAL, HELVETICA"><B>Tip 6: Use multi-byte functions
for Xlib code fragment.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Use <CODE>XmbDrawString() </CODE>instead of
<CODE>XDrawString() </CODE>for drawing text. (or
<CODE>XwcDrawString()</CODE>) </FONT>
<P></P>
<LI><FONT size=+0>Use <CODE>XmbLookupString() </CODE>instead of
<CODE>XLookupString() </CODE>for handling X events directly. (or
<CODE>XwcLookupString() </CODE>) </FONT></UI><FONT
color=#000000></FONT></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 7:
Use multi-byte functions for text processing.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Do not assume characters are ASCII (1 byte, 7 bit).
Some code sets use 8 bit for characters, while others may use multi byte
(and 8 bit) characters. </FONT>
<P></P>
<LI><FONT size=+0>Use multi byte or wide character functions for text
processing such as <CODE>mbtowc(), mbstowcs(), iswupper(), and
isideogram()</CODE>. </FONT>
<P></P>
<LI><FONT size=+0>In some languages, there are no spaces between words.
This may affect algorithms for justification, pagination, word wrapping,
etc. </FONT></UI></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 8:
Use Selection for Cut & Paste on Xlib base program.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Use Selection instead of Cut Buffer for Cut &
Paste (inter-client communication). </FONT>
<P></P>
<LI><FONT size=+0>Use compound texts for inter-client communications.
Conversion to compound text is required. </FONT></UI></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 9:
Use <CODE>LC_MESSAGES </CODE>for getting message catalogs.</B></FONT>
<P><UI></P>
<UL>
<LI><FONT size=+0>Be sure to use the <CODE>LC_MESSAGES
</CODE>sub-category when deciding where to get message catalogs, HTML
files, etc. Do NOT use the <CODE>LANG </CODE>environment variable
directly and do not use <CODE>LC_ALL for querying</CODE>. </FONT>
<P></P>
<LI><FONT size=+0>When calling <CODE>catopen()</CODE>, specify an
<CODE>OFLAG </CODE>of <CODE>NL_CAT_LOCALE </CODE>. The man page for
catopen says that this value must be 0, but the man page is out of date.
The correct value is <CODE>NL_CAT_LOCALE </CODE>. </FONT></UI><FONT
color=#000000></FONT><BR><FONT size=+0></FONT></LI></UL>
<P><BR><FONT size=+0></FONT></P><FONT face="ARIAL, HELVETICA"><B>Tip 10:
Use XPG4 message system function instead of
<CODE>gettxt()</CODE></B></FONT>
<P><FONT size=+0>Use the XPG4 message catalog functions (e.g. catopen(),
catgets()). Some older interfaces (such as getttxt) are supported for
compatibility but are deprecated. You may still use the getxt command in
shell scripts.</FONT> </P></TD></TR></TBODY></TABLE>
<P>
<CENTER><!---- Virtual Footer ---->
<TABLE border=0 cellPadding=0 width=400>
<TBODY>
<TR>
<TD align=right><FONT face="Helvetica, Arial" size=-1><A
href="http://www.sgi.com/company_info/privacy.html" target=TOP>privacy
policy</A></FONT> </TD>
<TD align=middle><FONT face="Helvetica, Arial">| </FONT></TD>
<TD align=left><FONT face="Helvetica, Arial" size=-1><A
href="mailto:dev_webmaster@sgi.com" target=_top>webmaster</A></FONT>
</TD></TR>
<TR>
<TD align=right><FONT face="Helvetica, Arial" size=-2><A
href="http://www.sgi.com/company_info/copyright.html"
target=_top>Copyright © 2000 Silicon Graphics, Inc.</A> All rights
reserved.</FONT> </TD>
<TD align=middle><FONT face="Helvetica, Arial">| </FONT></TD>
<TD align=left><FONT face="Helvetica, Arial" size=-2><A
href="http://www.sgi.com/company_info/trademarks/" target=_top>Trademark
Information</A></FONT> </TD></TR></TBODY></TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -