Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to <a href="http://www.siao2.com/2004/12/31/344739.aspx" rel="nofollow">this blog post</a>, for the words <strong>cote</strong>, <strong>coté</strong>, <strong>côte</strong> and <strong>côté</strong> (already sorted in English), the sorting order in French is: <strong>cote</strong>, <strong>côte</strong>, <strong>coté</strong> and <strong>côté</strong>. The code below sorts the words in the French collation:</p> <pre><code>$words = array('cote', 'coté', 'côte', 'côté'); print_r($words); $collator = new Collator('fr_FR'); // print info about locale echo 'French Collation ' . (($collator-&gt;getAttribute(Collator::FRENCH_COLLATION) == Collator::ON) ? 'On' : 'Off') . "\n"; echo $collator-&gt;getLocale(Locale::VALID_LOCALE) . "\n"; echo $collator-&gt;getLocale(Locale::ACTUAL_LOCALE) . "\n"; $collator-&gt;asort($words); print_r($words); </code></pre> <p>And the printed result is as follows:</p> <pre><code>Array ( [0] =&gt; cote [1] =&gt; coté [2] =&gt; côte [3] =&gt; côté ) French Collation On fr_FR fr Array ( [0] =&gt; cote [2] =&gt; côte [1] =&gt; coté [3] =&gt; côté ) </code></pre> <p>In the same blog post the author says:</p> <blockquote> <p>[...] diacritics are evaluated from right to left rather than from left to right. Thus <strong>côte</strong> comes before <strong>coté</strong>, rather than after it as it does in languages like English that evaluate them from left to right. Because the word <strong>côte</strong> has no ACUTE on the "e" at the end of the word while <strong>coté</strong> does. In English and most other languages, the evaluation starts on the left and therefore the CIRCUMFLEX or lack thereof on the "o" is the controlling factor in ordering.</p> </blockquote> <p>So, if you have an array with the words <strong>Spain</strong> and <strong>US</strong>, they will have the same order in English and French.</p> <p>You should also keep in mind that the <code>asort</code> method maintain the index association of the array. See the difference:</p> <pre><code>asort: Array ( [0] =&gt; cote [2] =&gt; côte [1] =&gt; coté [3] =&gt; côté ) sort: Array ( [0] =&gt; cote [1] =&gt; côte [2] =&gt; coté [3] =&gt; côté ) </code></pre> <h2>About U_USING_DEFAULT_WARNING</h2> <p>According to this <a href="http://www.icu-project.org/apiref/icu4c/classicu_1_1ResourceBundle.html" rel="nofollow">API documentation</a>:</p> <blockquote> <p>U_USING_DEFAULT_WARNING indicates that the default locale data was used; neither the requested locale nor any of its fall back locales could be found.</p> </blockquote> <p>When I use the <strong>fr_FR</strong> locale, for example, I get an U_USING_FALLBACK_WARNING, which indicates that a fall back locale was used, in this case the locale <strong>fr</strong>.</p> <h1>Locale</h1> <p>As it seems, your computer does not have support to the French language (or it does, but somehow PHP can't use it and then fallback to the default language), even though the command <code>locale -a</code> displays the French packages. I have some suggestions you can try.</p> <p>First, list all the supported locales:</p> <pre><code>cat /usr/share/i18n/SUPPORTED </code></pre> <p>Now, generate the languages you need:</p> <pre><code>sudo locale-gen fr_FR.UTF-8 sudo locale-gen fr_FR.ISO-8859-1 sudo dpkg-reconfigure locales </code></pre> <p>If it doesn't work, try to install the packages <strong>language-pack-fr</strong> and <strong>language-support-fr</strong> and generate the languages again.</p> <p>This problem is odd. I have an VM with Ubuntu 11.04 and PHP 5.3.8 and it works just fine, in my Debian 6 too, and I haven't installed any package or configured anything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload