Re: [Tiki-devel] A Unicode-aware replacement for the natcasesort() function
Jean-Marc Libs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <CA++RN4eH9j57PpDbG3-6zYN-5DfzNYoKEb5scDt9d+ViFznfWw@mail.gmail.com> |
Hi Volker,
This is how tiki-check.php does it:
// intl
$s = extension_loaded('intl');
if ($s) {
$php_properties['intl'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra("The intl extension is required for Tiki 15 and newer.")
);
} else {
$php_properties['intl'] = array(
'fitness' => tra('unsure'),
'setting' => 'Not available',
'message' => tra("intl extension is preferred for Tiki 15 and newer.
Because is not available, the filters for text will not be able to detect
the language and will use a generic range of characters as letters.")
);
}
On Sat, Jul 8, 2023 at 1:59 PM Volker Wysk <post-hhF2Jplw28UoZk/[email protected]> wrote:
> Hi.
>
> Does anyone know how to check if the intl PHP extension is available?
>
> Bye
> V.W.
>
> Am Freitag, dem 07.07.2023 um 13:31 +0200 schrieb Volker Wysk:
> > Hi!
> >
> > Here it is:
> >
> >
> ----------------------------------------------------------------------------
> > // Do a natural, locale aware sort of an array of strings.
> > //
> > // "Natural" means that numbers are sorted by their value, not by the
> digits
> > // they contain. For instance, "10" is ordered after "2".
> > //
> > // The "lang" argument is the language for which to order. Accented
> > // characters, like "ä", are ordered with their non-accented
> counterpart,
> > // like "a". In the non-locale aware natcasesort() function, accented
> > // characters get ordered at the end. That's not right for non-English
> > // languages.
> > //
> > // For the "lang" argument, "false" can be specified. In this case, the
> > // function investigates the language of the current user and uses that.
> > //
> > // mb_natcasesort() depends on the "intl" PHP extension.
> >
> > function mb_natcasesort(string $lang, array &$array): bool
> > {
> > if ($lang == false) {
> > $tikilib = TikiLib::lib('tiki');
> > $loginlib = TikiLib::lib('login');
> >
> > $user = $loginlib->getUser();
> > $lang = $tikilib->get_language($user);
> > }
> >
> > $coll = collator_create($lang);
> > collator_set_attribute($coll, Collator::NUMERIC_COLLATION,
> > Collator::ON);
> > collator_set_attribute($coll, Collator::CASE_FIRST,
> > Collator::LOWER_FIRST);
> > collator_set_attribute($coll, Collator::ALTERNATE_HANDLING,
> > Collator::SHIFTED);
> >
> > return collator_asort($coll, $array);
> > }
> >
> ----------------------------------------------------------------------------
> >
> > Any comments are welcome.
> >
> > Regards,
> > Volker
> > _______________________________________________
> > TikiWiki-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
> _______________________________________________
> TikiWiki-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel