string will be accepted as a locale name.)
See <ulink url="http://userguide.icu-project.org/locale"></ulink> for
information on ICU locale naming. <command>initdb</command> uses the ICU
- APIs to extract a set of locales with distinct collation rules to populate
- the initial set of collations. Here are some example collations that
- might be created:
+ APIs to extract a set of distinct locales to populate the initial set of
+ collations. Here are some example collations that might be created:
<variablelist>
<varlistentry>
<listitem>
<para>German collation for Austria, default variant</para>
<para>
- (As of this writing, there is no,
- say, <literal>de-DE-x-icu</literal> or <literal>de-CH-x-icu</literal>,
- because those are equivalent to <literal>de-x-icu</literal>.)
+ (There are also, say, <literal>de-DE-x-icu</literal>
+ or <literal>de-CH-x-icu</literal>, but as of this writing, they are
+ equivalent to <literal>de-x-icu</literal>.)
</para>
</listitem>
</varlistentry>
<para>German collation for Austria, phone book variant</para>
</listitem>
</varlistentry>
+
<varlistentry>
<term><literal>und-x-icu</literal> (for <quote>undefined</quote>)</term>
<listitem>
<programlisting>
CREATE COLLATION german FROM "de_DE";
CREATE COLLATION french FROM "fr-x-icu";
-CREATE COLLATION "de-DE-x-icu" FROM "de-x-icu";
</programlisting>
</para>
}
#endif /* READ_LOCALE_A_OUTPUT */
- /* Load collations known to ICU */
+ /*
+ * Load collations known to ICU
+ *
+ * We use uloc_countAvailable()/uloc_getAvailable() rather than
+ * ucol_countAvailable()/ucol_getAvailable(). The former returns a full
+ * set of language+region combinations, whereas the latter only returns
+ * language+region combinations of they are distinct from the language's
+ * base collation. So there might not be a de-DE or en-GB, which would be
+ * confusing.
+ */
#ifdef USE_ICU
{
int i;
* Start the loop at -1 to sneak in the root locale without too much
* code duplication.
*/
- for (i = -1; i < ucol_countAvailable(); i++)
+ for (i = -1; i < uloc_countAvailable(); i++)
{
/*
* In ICU 4.2, ucol_getKeywordValuesForLocale() sometimes returns
if (i == -1)
name = ""; /* ICU root locale */
else
- name = ucol_getAvailable(i);
+ name = uloc_getAvailable(i);
langtag = get_icu_language_tag(name);
collcollate = U_ICU_VERSION_MAJOR_NUM >= 54 ? langtag : name;