Announcement

#1 2023-01-18 15:44:19

BigIsland270972
Member
Norway
2022-03-15
374

Alphabetic sorting Norwegian

Hello/Hi/Greetings,

This is the norwegian alphabet:
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 Æ Ø Å
But how do i get Piwigo to automatically sort the pictures and albums in this order??

As you can see we have ÆØÅ at the end.

Piwigo 13.4

Best Regards
Robert


Piwigo URL: http://

Last edited by BigIsland270972 (2023-01-18 17:25:30)


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

#2 2023-01-19 09:13:41

BigIsland270972
Member
Norway
2022-03-15
374

Re: Alphabetic sorting Norwegian

It looks like A and Å is sorted at the beginning.But A is the first letter and Å is the last letter.


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

#3 2023-01-19 12:18:06

erAck
Only trying to help
2015-09-06
2027

Re: Alphabetic sorting Norwegian

Album sorting (assuming that the code in question for sorting album names is in admin/albums.php the array_multisort() call), maybe to cater for stupid non-UTF-8 environments, does some crappy thing where it calls a remove_accents() function on strings to be compared, so A and Å are equivalent. But even without that, the PHP SORT_REGULAR likely (hopefully) uses standard untailored Unicode Collation Algorithm (UCA) with the same result. Iff your web server runs in the proper Norwegian locale (either nb_NO.UTF-8 for Norwegian Bokmål or nn_NO.UTF-8 for Norwegian Nynorsk) then you could try to comment out the remove_accents() call on line 107 and in the array_multisort() call on line 118 change the SORT_REGULAR to SORT_LOCALE_STRING. After that you'd have to change album sort order twice, once to some other sorting and then back to name.

For picture names it gets hairy and I don't have an adhoc ready solution. It involves setting the MySQL database piwigo_images tables' collation, so if that is utf8mb4 or utf8mb4_general_ci or utf8mb4_unicode_ci (or utf8mb3... or utf8...), you could try to set it to utf8mb4_danish_ci (there is no ..._norwegian_ci) and see whether that works out already. See https://dev.mysql.com/doc/refman/5.7/en … -sets.html

Whatever you do, do backups before..


Running Piwigo at https://erack.net/gallery/

Offline

 

#4 2023-01-19 14:52:36

k5
Member
2017-11-05
68

Re: Alphabetic sorting Norwegian

since mysql 8.0.30 there is utf8mb4_nb_0900_ai_ci
but you should test

Offline

 

#5 2023-01-19 20:15:09

erAck
Only trying to help
2015-09-06
2027

Re: Alphabetic sorting Norwegian

Ah right, MySQL 8 added better Unicode support.
https://dev.mysql.com/doc/refman/8.0/en … -sets.html

And it gets a little more complicated. One could specify database and/or table character sets.
https://dev.mysql.com/doc/refman/8.0/en … yntax.html
Piwigo creates new tables with the collation specified as
define('DB_COLLATE', '');
in local/config/database.inc.php (default empty).

Best would be if Piwigo also supported the COLLATE clause when select querying with ORDER BY and use a collation as specified by the user / Piwigo admin.
https://dev.mysql.com/doc/refman/8.0/en … llate.html


Running Piwigo at https://erack.net/gallery/

Offline

 

#6 2023-01-19 22:15:13

BigIsland270972
Member
Norway
2022-03-15
374

Re: Alphabetic sorting Norwegian

erAck wrote:

Album sorting (assuming that the code in question for sorting album names is in admin/albums.php the array_multisort() call), maybe to cater for stupid non-UTF-8 environments, does some crappy thing where it calls a remove_accents() function on strings to be compared, so A and Å are equivalent. But even without that, the PHP SORT_REGULAR likely (hopefully) uses standard untailored Unicode Collation Algorithm (UCA) with the same result. Iff your web server runs in the proper Norwegian locale (either nb_NO.UTF-8 for Norwegian Bokmål or nn_NO.UTF-8 for Norwegian Nynorsk) then you could try to comment out the remove_accents() call on line 107 and in the array_multisort() call on line 118 change the SORT_REGULAR to SORT_LOCALE_STRING. After that you'd have to change album sort order twice, once to some other sorting and then back to name.

For picture names it gets hairy and I don't have an adhoc ready solution. It involves setting the MySQL database piwigo_images tables' collation, so if that is utf8mb4 or utf8mb4_general_ci or utf8mb4_unicode_ci (or utf8mb3... or utf8...), you could try to set it to utf8mb4_danish_ci (there is no ..._norwegian_ci) and see whether that works out already. See https://dev.mysql.com/doc/refman/5.7/en … -sets.html

Whatever you do, do backups before..

Your suggestion kind of worked but ÆØÅ  is now sorted   ÆÅØ :)


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

#7 2023-01-19 23:47:58

erAck
Only trying to help
2015-09-06
2027

Re: Alphabetic sorting Norwegian

¯\_(ツ)_/¯


Running Piwigo at https://erack.net/gallery/

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact