Pages: 1
Hello/Hi/Greetings,
so friends, after few hours surfing the forum and google I see that Piwigo doesn't work with non-English letters in the file/folder names, am I right? I would much appreciate you if you correct my belief.
What is my problem exactly?
I have a lot of folders (and some files) on my NAS Synology (tested not only on Synology but on usual Windows folder) with Cyrillic letters in the names. I vote for English naming, but not only me use these folders. Rename all of them is not proper solution, better I'll find another soft.
These folders are symlinked (mount --bind) to "gallery" folder of Piwigo. When I try to sync them I've got the message:
"[./galleries/photoalbum/день_рожденья] PWG-UPDATE-1 (wrong filename)"
I tried to add this param to config.inc.php in /local/config/ but without success, the problem wasn't solved:
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]-_.\sйцукенгшщзхїфівапролджєячсмитьбюЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮёЁъЪыЫэЭ!\(\)\&\/\°\'\,]+$/';
If I create Cyrillic album in Piwigo, of course, it works properly, as physically it isn't Cyrillic folder in structure, just a name in DB.
Do you know any solution?
Piwigo version: 2.10.2
PHP version: 7.3.11
MySQL version: 5.5.62-MariaDB
Piwigo URL: http://sorry it's closed for all
Offline
Operating system? What locale settings do you have? I assume Piwigo like all modern software requires UTF-8 in the file system.
Offline
Zentalquabula wrote:
Operating system? What locale settings do you have? I assume Piwigo like all modern software requires UTF-8 in the file system.
Yes, there is UTF-8, all folders were created in Windows 10 and local is Ukrainian which is very similar to Russian.
Offline
As $conf['sync_chars_regex'] is used with the PHP preg_match() function you may have to append the u modifier to make that work. Make sure the editor you use writes file content in UTF-8 encoding and that the web server process also runs in UTF-8 locale context. It might also unlikely be your PHP wasn't compiled with UTF-8 for PCRE, in that case prepend a (*UTF8) to the regex. You can also try to express the Cyrillic characters as Unicode code points, e.g. й would be \x{0439} and so on. Instead of listing each individually you can also use a range, e.g. \x{0439}-\x{044E} or whatever suits there.
See https://www.php.net/manual/en/function.preg-match.php
Offline
These modifications didn't solve the issue.
setlocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_NUMERIC, 'C');
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]-_.\s\x{0410}-\x{044F}\(\)\&\/\°\'\,]+$/';
I'm sorry, I'm not good in PHP, what did I do wrong?
Offline
The actual Cyrillic script Unicode range is larger than just \x{0410}-\x{044F} so probably you're missing characters there. For example these characters of your previous expression are not in that range:
ЁЄІЇёєії
which are 0x401 0x404 0x406 0x407 0x451 0x454 0x456 0x457
There are several Cyrillic script blocks (i.e. also Supplement, Extended-A,-B,-C), you seem to use range U+0400 to U+045F of the block U+0400 to U+04FF, see https://r12a.github.io/uniview/?block=cyrillic
You can test your expression against single file names at https://regex101.com/ with the PCRE (PHP) flavor.
Btw, the \ backslash escape for the single characters \(\)\&\/\°\'\, is not needed in the character list, except for the / forward slash, it just makes the expression less readable. That could be ()&°',\/ instead.
Offline
erAck wrote:
The actual Cyrillic script Unicode range is larger than just \x{0410}-\x{044F} so probably you're missing characters there. For example these characters of your previous expression are not in that
...
Btw, the \ backslash escape for the single characters \(\)\&\/\°\'\, is not needed in the character list, except for the / forward slash, it just makes the expression less readable. That could be ()&°',\/ instead.
Done! Thanks much, erAck!
But I did some additional steps:
1) set collation to utf8mb4_unicode_ci for DB;
2) config.inc.php was changed with:
setlocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_NUMERIC, 'C');
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]\_.\s\x{0400}-\x{04FF}()&\/°\',!\-]+$/u';
'u' at the end, \- and \' were the stumbling stones.
Now everything works fine.
Offline
Btw, you should remove the \' apostrophe, at least with directory names it does not work and may or may not (or only partially) work with file names, see [Forum, topic 30356] Directory Names with ' in.
Offline
This sign is used in Ukrainian, e.g. Кам'яна, say frankly that isn't a real apostrophe, but thank for your help!
This char could be used in FS file naming.
Offline
Nevertheless the character you used is
U+0027 ' APOSTROPHE
however the context might be in your language. The apostrophe does confuse some processing hence should not appear in the regex.
Offline
You're right. It causes. Checked on filenames with \'. Excluded it from naming.
Offline
Guys, I've faced with the same problem. I've made all the recommendations, but sync works strange.
For example
I have album "2002/Дорога домой" (2002 is a top level album)
Synchronisation add this album with no errors, but when I open it in album it called "2002/ домой"
It removes first Cyrillic word. And if I try to sync it next time it removes this album and then add it one more time. And the situation repeats.
If I put any digit or symbol before Cyrillic word - everything is like a charm.
What should I do?
p.s. Piwigo 13.4.0
Last edited by Viva (2022-12-17 17:31:56)
Offline
exogadget wrote:
Done! Thanks much, erAck!
But I did some additional steps:
1) set collation to utf8mb4_unicode_ci for DB;
2) config.inc.php was changed with:
setlocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_NUMERIC, 'C');
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]\_.\s\x{0400}-\x{04FF}()&\/°\',!\-]+$/u';
'u' at the end, \- and \' were the stumbling stones.
Now everything works fine.
[s]I've made the same steps, DB itself and all tables are utf8mb4_unicode_ci now.
But Piwigo can't even add a standalone pic outside cyrillic named folder.
[/s]
My fault. Apologies for my post.
Everything works fine now and no need to change collation to utf8mb4_unicode_ci for DB
Piwigo 13.5.0
Installed on 14 February 2023, 14 hours ago
Operating system: WINNT - Windows 7 x64
PHP: 7.4.33
MySQL: 5.5.27
Graphics Library: GD bundled (2.1.0 compatible)
Last edited by a33mail2013 (2023-02-16 22:25:43)
Offline
Pages: 1