@@ -534,6 +534,12 @@ void SkkEngine::loadDictionary() {
534534 continue ;
535535 }
536536 if (mode == 1 ) {
537+ std::string_view partialpath = path;
538+ if (stringutils::consumePrefix (partialpath,
539+ " $XDG_DATA_DIRS/" )) {
540+ path = StandardPath::global ().locate (
541+ StandardPath::Type::Data, std::string (partialpath));
542+ }
537543 if (stringutils::endsWith (path, " .cdb" )) {
538544 SkkCdbDict *dict =
539545 skk_cdb_dict_new (path.data (), encoding.data (), nullptr );
@@ -550,19 +556,18 @@ void SkkEngine::loadDictionary() {
550556 }
551557 }
552558 } else {
553- constexpr char configDir[] = " $FCITX_CONFIG_DIR/" ;
554- constexpr auto len = sizeof (configDir) - 1 ;
555- std::string realpath = path;
556- if (stringutils::startsWith (path, configDir)) {
557- realpath = stringutils::joinPath (
559+ std::string_view partialpath = path;
560+ if (stringutils::consumePrefix (partialpath,
561+ " $FCITX_CONFIG_DIR/" )) {
562+ path = stringutils::joinPath (
558563 StandardPath::global ().userDirectory (
559564 StandardPath::Type::PkgData),
560- path. substr (len) );
565+ partialpath );
561566 }
562- SkkUserDict *userdict = skk_user_dict_new (
563- realpath .data (), encoding.data (), nullptr );
567+ SkkUserDict *userdict =
568+ skk_user_dict_new (path .data (), encoding.data (), nullptr );
564569 if (userdict) {
565- SKK_DEBUG () << " Adding user dict: " << realpath ;
570+ SKK_DEBUG () << " Adding user dict: " << path ;
566571 dictionaries_.emplace_back (SKK_DICT (userdict));
567572 }
568573 }
0 commit comments