Added alpha index guides 13/153913/4
authorLukasz Pik <lu.pik@samsung.com>
Tue, 3 Oct 2017 09:57:34 +0000 (11:57 +0200)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Fri, 6 Oct 2017 07:40:15 +0000 (10:40 +0300)
PS2: Reviewed
PS4: Reviewed

Change-Id: Ic8787a3e41389838efc5f703c42eea0da8453558
Signed-off-by: Lukasz Pik <lu.pik@samsung.com>
org.tizen.guides/html/native/internationalization/i18n_n.htm

index 5d811b7..b1fd132 100644 (file)
@@ -42,6 +42,7 @@
                        <li><a href="#usearch">Text Search with Usearch</a></li>
                        <li><a href="#uset">Character and String Management with Uset</a></li>
                        <li><a href="#ustring">Unicode Strings with Ustring</a></li>
+                       <li><a href="#alpha_idx">Alphabetic Index Creation</a></li>
                        <li><a href="#uchar_iter">String Iteration with UCharIter</a></li>
                        <li><a href="#prerequisites">Prerequisites</a></li>
                        <li><a href="#characters">Managing Characters and Strings</a></li>
@@ -52,6 +53,7 @@
                        <li><a href="#uenum">Managing Enumerations</a></li>
                        <li><a href="#tmz">Managing Time Zones</a></li>
                        <li><a href="#manage_uset">Managing Sets</a></li>
+                       <li><a href="#alpha_idx_example">Managing Alphabetic Indexes</a></li>
                        <li><a href="#manage_version">Retrieving the ICU Version</a></li>
                        <li><a href="#uchar_iter_examples">Iterating through Strings</a></li>
                </ul>
@@ -85,6 +87,8 @@
        <li>Managing locales and time zones
        <p>You can use the Ulocale functions to <a href="#ulocale">tailor information according to a specific geographical, cultural, or political region</a>. With the Timezone functions, you can <a href="#tmz">get the time zone name, ID, DST settings, raw offset, and region code</a>.</p>
        </li>
+       <li>Managing alphabetic indexes
+       <p>You can use the Alphabetic Index functions to <a href="#alpha_idx">generate a list of labels</a> that can be used as an index.</p></li>
        <li>Retrieving the ICU version
        <p>You can <a href="#manage_version">retrieve the currently-used version of the ICU library</a> with Uversion.</p></li>
        <li>Iterating through strings
@@ -94,7 +98,7 @@
 
        <div class="note">
        <strong>Note</strong>
-       The Uversion and UCharIter APIs are supported since Tizen 4.0.
+       The Alphabetic Index API is supported since Tizen 3.0. The Uversion and UCharIter APIs are supported since Tizen 4.0.
        </div>
 
 <h2 id="ubrk" name="ubrk">Location Boundaries with Ubrk</h2>
 <p>For more information on character sets, codepages, and encodings, see <a href="http://www.ibm.com/software/globalization/topics/charsets/" target="_blank">Coded Character Sets</a> on the IBM site.
 </p>
 
+<h2 id="alpha_idx" name="alpha_idx">Alphabetic Index Creation</h2>
+<p>The Alphabetic Index API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__ALPHA__IDX__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__ALPHA__IDX__MODULE.html">wearable</a> applications) allows you to <a href="#alpha_idx_example">generate a list of alphabetical labels</a> that can be used as an "index", such as in a UI. In other words, it is a list of clickable characters (or character sequences) that allow the user to see a segment (bucket) of a larger target list. Each label corresponds to a bucket in the target list, where all items in the bucket are greater than or equal to the selected character, based on the locale's collation order. Strings added to the index are sorted and placed in order in the appropriate bucket.</p>
+<p>You can use the index directly, or with a client that does not support localized collation. The following example shows an alphabetical index.</p>
+<table><tr><td><p><strong>... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  ...</strong></p>
+ <p><strong>A</strong></p>
+ <ul>
+    <li>Addison</li>
+    <li>Albertson</li>
+    <li>Azensky</li>
+</ul>
+ <p><strong>B</strong></p>
+ <ul>
+    <li>Baker</li>
+       <li>...</li>
+</ul></td></tr></table>
+
+<p>The Alphabetic Index API also supports creating buckets for strings that are sorted before the first label (underflow), after the last label (overflow), and between scripts (inflow). For example, if an index is constructed with labels for Russian and for English characters, Greek characters can be placed in an inflow bucket between the other 2 scripts.</p>
+
+
 <h2 id="uchar_iter" name="uchar_iter">String Iteration with UCharIter</h2>
 <p>The UCharIter API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__UCHARITER__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__UCHARITER__MODULE.html">wearable</a> applications) allows you to <a href="#uchar_iter_examples">iterate through strings</a>.</p>
 <p>The <code>current()</code> and <code>next()</code> functions only check the current index against the limit, and the <code>previous()</code> function only checks the current index against the start, to see if the iterator has already reached the beginning of the iteration range. The assumption - in all iterators - is that the index is moved though the API, which means that it cannot go out of bounds, or that the index is modified though the application code by a developer who knows enough about the iterator implementation to set valid index values.</p>
@@ -1586,6 +1609,168 @@ i18n_ubool contains = i18n_uset_contains_string(set, input_ustring, -1);
 </li>
 </ol>
 
+<h2 id="alpha_idx_example" name="alpha_idx_example">Managing Alphabetic Indexes</h2>
+<p>Since Tizen 3.0, you can generate an alphabetical list of clickable labels by using the Alphabetic Index API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__ALPHA__IDX__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__ALPHA__IDX__MODULE.html">wearable</a> applications).</p>
+<p>To generate and manage an alphabetic index:</p>
+<ol>
+<li>To create an alphabetic index object for a specific locale:
+<pre class="prettyprint">
+i18n_alpha_idx_create("en", "US", &amp;alpha_idx);
+</pre></li>
+<li>To manage index labels:
+<ul>
+<li>To add labels from a specific locale:
+<pre class="prettyprint">
+i18n_alpha_idx_add_labels(alpha_idx, "ko", "KR");
+</pre></li>
+<li>To add custom labels to the index:
+<pre class="prettyprint">
+int record_data = 7;
+i18n_alpha_idx_add_record(alpha_idx, "AAA", &amp;record_data); /* Adds label "AAA" at position 7 in index */
+</pre></li>
+<li>To manage the default label used for abbreviated buckets between other index characters:
+<ul>
+<li>To get the default label:
+<pre class="prettyprint">
+char *label = NULL;
+i18n_alpha_idx_get_inflow_label(alpha_idx, &amp;label);
+</pre></li>
+<li>To set the default label:
+<pre class="prettyprint">
+const char *label = "Desired label";
+i18n_alpha_idx_set_inflow_label(alpha_idx, label);
+</pre></li>
+</ul></li>
+<li>To manage the overflow label used for items sorted after the last normal label:
+<ul>
+<li>To get the overflow label:
+<pre class="prettyprint">
+char *label;
+i18n_alpha_idx_get_overflow_label(alpha_idx, &amp;label);
+</pre></li>
+<li>To set the overflow label:
+<pre class="prettyprint">
+char *label = "Overflow label";
+i18n_alpha_idx_set_overflow_label(alpha_idx, label);
+</pre></li>
+</ul></li>
+<li>To manage the underflow label used for items sorted before the first normal label:
+<ul>
+<li>To get the underflow label:
+<pre class="prettyprint">
+char *label;
+i18n_alpha_idx_get_underlow_label(alpha_idx, &amp;label);
+</pre></li>
+<li>To set the underflow label:
+<pre class="prettyprint">
+char *label = "Underflow label";
+i18n_alpha_idx_set_underflow_label(alpha_idx, label);
+</pre></li>
+</ul></li>
+<li>To manage the number of labels permitted in the index:
+<ul>
+<li>To get the number of labels permitted in the index:
+<pre class="prettyprint">
+int32_t count = 0;
+i18n_alpha_idx_get_max_label_count(alpha_idx, &amp;count);
+</pre></li>
+<li>To set the number of labels permitted in the index:
+<pre class="prettyprint">
+int32_t count = 50;
+i18n_alpha_idx_set_max_label_count(alpha_idx, count);
+</pre></li></ul>
+</li>
+<li>To get the label of the current bucket:
+<pre class="prettyprint">
+char *record_name;
+i18n_alpha_idx_get_bucket_label(alpha_idx, &amp;record_name);
+</pre></li>
+<li>To get the label type of the current bucket:
+<pre class="prettyprint">
+i18n_alpha_idx_label_type_e type;
+i18n_alpha_idx_get_bucket_label_type(alpha_idx, &amp;type);
+</pre></li>
+</ul></li>
+<li>To move around the index:
+<ul>
+<li>To set the next bucket as the current bucket:
+<pre class="prettyprint">
+bool available;
+i18n_alpha_idx_get_next_bucket(alpha_idx, &amp;available);
+</pre></li>
+<li>To set the next record as the current record in the current bucket:
+<pre class="prettyprint">
+bool available;
+i18n_alpha_idx_get_next_record(alpha_idx, &amp;available);
+</pre></li>
+<li>To reset the iterators:
+<ul>
+<li>To reset the bucket iterator:
+<pre class="prettyprint">
+i18n_alpha_idx_reset_bucket_iter(alpha_idx);
+</pre>
+The iterator is set before the first bucket. To move the iterator to the first bucket, use the <code>i18n_alpha_idx_next_bucket()</code> function.</li>
+<li>To reset the record iterator:
+<pre class="prettyprint">
+i18n_alpha_idx_reset_record_iter(alpha_idx);
+</pre>
+The iterator is set before the first record in the current bucket. To move the iterator to the first record, use the <code>i18n_alpha_idx_next_record()</code> function.</li></ul>
+</li>
+</ul></li>
+<li>To retrieve information:
+<ul>
+<li>To get the number of various objects in the index:
+<ul>
+<li>To get the number of buckets in the index:
+<pre class="prettyprint">
+int32_t count = 0;
+i18n_alpha_idx_get_bucket_count(alpha_idx, &amp;count);
+</pre></li>
+<li>To get the total number of records in all buckets:
+<pre class="prettyprint">
+int32_t count = 0;
+i18n_alpha_idx_get_record_count(alpha_idx, &amp;count);
+</pre></li>
+<li>To get the number of records in the current bucket:
+<pre class="prettyprint">
+int32_t count = 0;
+i18n_alpha_idx_get_bucket_record_count(alpha_idx, &amp;count);
+</pre></li></ul></li>
+<li>To get the bucket index:
+<ul>
+<li>For a bucket with a specific name:
+<pre class="prettyprint">
+int32_t index = -1;
+const char *name = "Desired bucket";
+i18n_alpha_idx_get_bucket_index(alpha_idx, name, &amp;index);
+</pre></li>
+<li>For the current bucket:
+<pre class="prettyprint">
+int32_t index = -1;
+i18n_alpha_idx_get_current_bucket_index(alpha_idx, &amp;index);
+</pre></li></ul></li>
+<li>To get the current record name:
+<pre class="prettyprint">
+char *name;
+i18n_alpha_idx_get_record_name(alpha_idx, &amp;name);
+</pre></li>
+<li>To get the pointer to the current record:
+<pre class="prettyprint">
+void *data = NULL;
+data = i18n_alpha_idx_get_record_data(alpha_idx);
+</pre></li>
+</ul></li>
+<li>To clear all records from the index:
+<pre class="prettyprint">
+i18n_alpha_idx_clear_records(alpha_idx);
+</pre></li>
+<li>When no longer needed, destroy the index:
+<pre class="prettyprint">
+i18n_alpha_idx_destroy(alpha_idx);
+</pre></li>
+</ol>
+
+
 <h2 id="manage_version" name="manage_version">Retrieving the ICU Version</h2>
 
 <p>Since Tizen 4.0, you can retrieve the current ICU library version by using the Uversion API.</p>