1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<html>
<head>
<title>EAGLE Help: language()</title>
</head>
<body bgcolor=white>
<font face=Helvetica,Arial>
<hr>
<i>EAGLE Help</i>
<h1><center>language()</center></h1>
<hr>
<dl>
<dt>
<b>Function</b>
<dd>
Returns the language code of the system in use.
<p>
<dt>
<b>Syntax</b>
<dd>
<tt>string language();</tt>
<p>
<dt>
<b>Returns</b>
<dd>
<tt>language</tt> returns a string consisting of two lowercase characters
that identifies the language used on the current system.
If no such language setting can be determined, an empty string will
be returned.
<p>
</dl>
The <tt>language</tt> function can be used to make a ULP use different
message string, depending on which language the current system is using.
<p>
In the example below all the strings used in the ULP are listed in the
string array <tt>I18N[]</tt>, preceeded by a string containing the
various language codes supported by this ULP. Note the <tt>vtab</tt>
characters used to separate the individual parts of each string (they
are important for the <tt>lookup</tt> function) and the use of the commas
to separate the strings. The actual work is done in the function <tt>tr()</tt>,
which returns the translated version of the given string.
If the original string can't be found in the <tt>I18N</tt> array, or there
is no translation for the current language, the original string will be used
untranslated.
<p>
The first language defined in the <tt>I18N</tt> array must be the one in which
the strings used throughout the ULP are written, and should generally be
English in order to make the program accessible to the largest number of users.
<p>
<b>Example</b>
<pre>
string I18N[] = {
"en\v"
"de\v"
"it\v"
,
"I18N Demo\v"
"Beispiel für Internationalisierung\v"
"Esempio per internazionalizzazione\v"
,
"Hello world!\v"
"Hallo Welt!\v"
"Ciao mondo!\v"
,
"+Ok\v"
"+Ok\v"
"+Approvazione\v"
,
"-Cancel\v"
"-Abbrechen\v"
"-Annullamento\v"
};
int Language = strstr(I18N[0], language()) / 3;
string tr(string s)
{
string t = lookup(I18N, s, Language, '\v');
return t ? t : s;
}
dlgDialog(tr("I18N Demo")) {
dlgHBoxLayout dlgSpacing(350);
dlgLabel(tr("Hello world!"));
dlgHBoxLayout {
dlgPushButton(tr("+Ok")) dlgAccept();
dlgPushButton(tr("-Cancel")) dlgReject();
}
};
</pre>
<hr>
<table width=100% cellspacing=0 border=0><tr><td align=left><font face=Helvetica,Arial>
<a href=index.htm>Index</a>
</font></td><td align=right><font face=Helvetica,Arial size=-1>
<i>Copyright © 2005 CadSoft Computer GmbH</i>
</font></td></tr></table>
<hr>
</font>
</body>
</html>
|