dlangui/docs/i18n.html

123 lines
3.6 KiB
HTML

<html><head>
<META http-equiv="content-type" content="text/html; charset=utf-8">
<title>dlangui.core.i18n</title>
</head><body>
<h1>dlangui.core.i18n</h1>
<!-- Generated by Ddoc from src/dlangui/core/i18n.d -->
DLANGUI library.
<br><br>
This module contains internationalization support implementation.
<br><br>
Translation files contain of simple key=value pair lines.
<br><br>
STRING_RESOURCE_ID=Translation text.
<br><br>
Supports fallback to another translation file (e.g. default language).
<br><br>
<br><br>
<br><br>
<b>Synopsis:</b><br>
<pre class="d_code"><font color=blue>import</font> dlangui.core.<u>i18n</u>;
<font color=green>// use global i18n object to get translation for string ID
</font>dstring translated = <u>i18n</u>.get(<font color=red>"STR_FILE_OPEN"</font>);
<font color=green>// UIString type can hold either string resource id or dstring raw value.
</font>UIString text;
<font color=green>// assign resource id as string
</font>text = <font color=red>"ID_FILE_EXIT"</font>;
<font color=green>// or assign raw value as dstring
</font>text = <font color=red>"some text"d</font>;
<font color=green>// i18n.get() will automatically be invoked when getting UIString value (e.g. using alias this).
</font>dstring translated = text;
</pre>
<br><br>
<b>License:</b><br>
Boost License 1.0
<br><br>
<b>Authors:</b><br>
Vadim Lopatin, coolreader.org@gmail.com<br><br>
<dl><dt><big><a name="UIString"></a>struct <u>UIString</u>;
</big></dt>
<dd>container for UI string - either raw value or string resource ID<br><br>
<dl><dt><big><a name="UIString.this"></a> this(string <i>id</i>);
</big></dt>
<dd>create string with i18n resource <i>id</i><br><br>
</dd>
<dt><big><a name="UIString.this"></a> this(dstring <i>value</i>);
</big></dt>
<dd>create string with raw <i>value</i><br><br>
</dd>
<dt><big><a name="UIString.value"></a>const @property dstring <u>value</u>();
</big></dt>
<dd>get <u>value</u> (either raw or translated by id)<br><br>
</dd>
<dt><big><a name="UIString.value"></a>@property void <u>value</u>(dstring <i>newValue</i>);
</big></dt>
<dd>set raw <u>value</u><br><br>
</dd>
<dt><big><a name="UIString.opAssign"></a>ref UIString <u>opAssign</u>(dstring <i>rawValue</i>);
</big></dt>
<dd>assign raw value<br><br>
</dd>
<dt><big><a name="UIString.opAssign"></a>ref UIString <u>opAssign</u>(string <i>ID</i>);
</big></dt>
<dd>assign <i>ID</i><br><br>
</dd>
</dl>
</dd>
<dt><big><a name="UIStringList"></a>class <u>UIStringList</u>;
</big></dt>
<dd>UI string translator<br><br>
<dl><dt><big><a name="UIStringList.clear"></a>void <u>clear</u>();
</big></dt>
<dd>remove all items<br><br>
</dd>
<dt><big><a name="UIStringList.set"></a>void <u>set</u>(string <i>id</i>, dstring <i>value</i>);
</big></dt>
<dd><u>set</u> item <i>value</i><br><br>
</dd>
<dt><big><a name="UIStringList.get"></a>const dstring <u>get</u>(string <i>id</i>);
</big></dt>
<dd><u>get</u> item value, <b>null</b> if translation is not found for <i>id</i><br><br>
</dd>
<dt><big><a name="UIStringList.load"></a>bool <u>load</u>(std.<i>stream</i>.InputStream <i>stream</i>);
</big></dt>
<dd><u>load</u> strings from <i>stream</i><br><br>
</dd>
<dt><big><a name="UIStringList.load"></a>bool <u>load</u>(string <i>filename</i>);
</big></dt>
<dd><u>load</u> strings from file (utf8, id=value lines)<br><br>
</dd>
</dl>
</dd>
</dl>
<hr><small>Page generated by <a href="http://dlang.org/ddoc.html">Ddoc</a>. Vadim Lopatin, 2014
</small>
</body></html>