@@ -501,18 +501,26 @@ void SkkEngine::loadDictionary() {
501
501
continue ;
502
502
}
503
503
if (mode == 1 ) {
504
- if (stringutils::endsWith (path, " .cdb" )) {
504
+ constexpr char xdgDataDirs[] = " $XDG_DATA_DIRS/" ;
505
+ constexpr auto len = sizeof (xdgDataDirs) - 1 ;
506
+ std::string realpath = path;
507
+ if (stringutils::startsWith (path, xdgDataDirs)) {
508
+ realpath = StandardPath::global ().locate (
509
+ StandardPath::Type::Data,
510
+ path.substr (len));
511
+ }
512
+ if (stringutils::endsWith (realpath , " .cdb" )) {
505
513
SkkCdbDict *dict =
506
- skk_cdb_dict_new (path .data (), encoding.data (), nullptr );
514
+ skk_cdb_dict_new (realpath .data (), encoding.data (), nullptr );
507
515
if (dict) {
508
- SKK_DEBUG () << " Adding cdb dict: " << path ;
516
+ SKK_DEBUG () << " Adding cdb dict: " << realpath ;
509
517
dictionaries_.emplace_back (SKK_DICT (dict));
510
518
}
511
519
} else {
512
520
SkkFileDict *dict = skk_file_dict_new (
513
- path .data (), encoding.data (), nullptr );
521
+ realpath .data (), encoding.data (), nullptr );
514
522
if (dict) {
515
- SKK_DEBUG () << " Adding file dict: " << path ;
523
+ SKK_DEBUG () << " Adding file dict: " << realpath ;
516
524
dictionaries_.emplace_back (SKK_DICT (dict));
517
525
}
518
526
}
0 commit comments