@@ -501,18 +501,25 @@ void SkkEngine::loadDictionary() {
501
501
continue ;
502
502
}
503
503
if (mode == 1 ) {
504
- if (stringutils::endsWith (path, " .cdb" )) {
505
- SkkCdbDict *dict =
506
- skk_cdb_dict_new (path.data (), encoding.data (), nullptr );
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, path.substr (len));
510
+ }
511
+ if (stringutils::endsWith (realpath, " .cdb" )) {
512
+ SkkCdbDict *dict = skk_cdb_dict_new (
513
+ realpath.data (), encoding.data (), nullptr );
507
514
if (dict) {
508
- SKK_DEBUG () << " Adding cdb dict: " << path ;
515
+ SKK_DEBUG () << " Adding cdb dict: " << realpath ;
509
516
dictionaries_.emplace_back (SKK_DICT (dict));
510
517
}
511
518
} else {
512
519
SkkFileDict *dict = skk_file_dict_new (
513
- path .data (), encoding.data (), nullptr );
520
+ realpath .data (), encoding.data (), nullptr );
514
521
if (dict) {
515
- SKK_DEBUG () << " Adding file dict: " << path ;
522
+ SKK_DEBUG () << " Adding file dict: " << realpath ;
516
523
dictionaries_.emplace_back (SKK_DICT (dict));
517
524
}
518
525
}
0 commit comments