From d3700f2926ee3f78ff012e4bceccb9309d623889 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Thu, 21 Nov 2024 02:21:57 -0500 Subject: [PATCH] refactor: move transliteration code to `src/dict/transliteration` --- src/dict/loaddictionaries.cc | 19 ++++++++++--------- src/dict/transliteration/README.md | 1 + .../belarusian.cc} | 2 +- .../belarusian.hh} | 1 - src/dict/{ => transliteration}/chinese.cc | 7 ++----- src/dict/{ => transliteration}/chinese.hh | 4 +--- .../custom.cc} | 2 +- .../custom.hh} | 1 - src/dict/{ => transliteration}/german.cc | 0 src/dict/{ => transliteration}/german.hh | 0 .../greek.cc} | 2 +- .../greek.hh} | 0 src/dict/{ => transliteration}/romaji.cc | 6 ++++-- src/dict/{ => transliteration}/romaji.hh | 9 +++------ .../russian.cc} | 2 +- .../russian.hh} | 0 .../{ => transliteration}/transliteration.cc | 0 .../{ => transliteration}/transliteration.hh | 0 18 files changed, 25 insertions(+), 31 deletions(-) create mode 100644 src/dict/transliteration/README.md rename src/dict/{belarusiantranslit.cc => transliteration/belarusian.cc} (99%) rename src/dict/{belarusiantranslit.hh => transliteration/belarusian.hh} (94%) rename src/dict/{ => transliteration}/chinese.cc (97%) rename src/dict/{ => transliteration}/chinese.hh (84%) rename src/dict/{customtransliteration.cc => transliteration/custom.cc} (97%) rename src/dict/{customtransliteration.hh => transliteration/custom.hh} (96%) rename src/dict/{ => transliteration}/german.cc (100%) rename src/dict/{ => transliteration}/german.hh (100%) rename src/dict/{greektranslit.cc => transliteration/greek.cc} (99%) rename src/dict/{greektranslit.hh => transliteration/greek.hh} (100%) rename src/dict/{ => transliteration}/romaji.cc (99%) rename src/dict/{ => transliteration}/romaji.hh (59%) rename src/dict/{russiantranslit.cc => transliteration/russian.cc} (98%) rename src/dict/{russiantranslit.hh => transliteration/russian.hh} (100%) rename src/dict/{ => transliteration}/transliteration.cc (100%) rename src/dict/{ => transliteration}/transliteration.hh (100%) diff --git a/src/dict/loaddictionaries.cc b/src/dict/loaddictionaries.cc index fc4bb737..a48981d1 100644 --- a/src/dict/loaddictionaries.cc +++ b/src/dict/loaddictionaries.cc @@ -11,12 +11,6 @@ #include "dict/sounddir.hh" #include "dict/hunspell.hh" #include "dictdfiles.hh" -#include "dict/romaji.hh" -#include "dict/customtransliteration.hh" -#include "dict/russiantranslit.hh" -#include "dict/german.hh" -#include "dict/greektranslit.hh" -#include "dict/belarusiantranslit.hh" #include "dict/website.hh" #include "dict/forvo.hh" #include "dict/programs.hh" @@ -34,12 +28,19 @@ #include "dict/lingualibre.hh" #include "metadata.hh" +#include "dict/transliteration/belarusian.hh" +#include "dict/transliteration/custom.hh" +#include "dict/transliteration/german.hh" +#include "dict/transliteration/greek.hh" +#include "dict/transliteration/romaji.hh" +#include "dict/transliteration/russian.hh" + #ifndef NO_EPWING_SUPPORT #include "dict/epwing.hh" #endif #ifdef MAKE_CHINESE_CONVERSION_SUPPORT - #include "dict/chinese.hh" + #include "dict/transliteration/chinese.hh" #endif #include @@ -243,10 +244,10 @@ void loadDictionaries( QWidget * parent, ///// We create transliterations synchronously since they are very simple #ifdef MAKE_CHINESE_CONVERSION_SUPPORT - addDicts( Chinese::makeDictionaries( cfg.transliteration.chinese ) ); + addDicts( ChineseTranslit::makeDictionaries( cfg.transliteration.chinese ) ); #endif - addDicts( Romaji::makeDictionaries( cfg.transliteration.romaji ) ); + addDicts( RomajiTranslit::makeDictionaries( cfg.transliteration.romaji ) ); addDicts( CustomTranslit::makeDictionaries( cfg.transliteration.customTrans ) ); // Make Russian transliteration diff --git a/src/dict/transliteration/README.md b/src/dict/transliteration/README.md new file mode 100644 index 00000000..23da4bf1 --- /dev/null +++ b/src/dict/transliteration/README.md @@ -0,0 +1 @@ +Translit \ No newline at end of file diff --git a/src/dict/belarusiantranslit.cc b/src/dict/transliteration/belarusian.cc similarity index 99% rename from src/dict/belarusiantranslit.cc rename to src/dict/transliteration/belarusian.cc index 85d50919..c3cbcb65 100644 --- a/src/dict/belarusiantranslit.cc +++ b/src/dict/transliteration/belarusian.cc @@ -1,7 +1,7 @@ /* This file is (c) 2013 Maksim Tamkovicz * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ -#include "belarusiantranslit.hh" +#include "belarusian.hh" #include "transliteration.hh" #include diff --git a/src/dict/belarusiantranslit.hh b/src/dict/transliteration/belarusian.hh similarity index 94% rename from src/dict/belarusiantranslit.hh rename to src/dict/transliteration/belarusian.hh index 43b06ce3..f8d17a98 100644 --- a/src/dict/belarusiantranslit.hh +++ b/src/dict/transliteration/belarusian.hh @@ -3,7 +3,6 @@ #pragma once -#include #include "dictionary.hh" // Support for Belarusian transliteration diff --git a/src/dict/chinese.cc b/src/dict/transliteration/chinese.cc similarity index 97% rename from src/dict/chinese.cc rename to src/dict/transliteration/chinese.cc index ef735813..12806a97 100644 --- a/src/dict/chinese.cc +++ b/src/dict/transliteration/chinese.cc @@ -4,16 +4,13 @@ #include "chinese.hh" #include #include -// #ifdef Q_OS_MAC #include -// #endif -// #include #include "folding.hh" #include "gddebug.hh" #include "transliteration.hh" #include "utf8.hh" -namespace Chinese { +namespace ChineseTranslit { class CharacterConversionDictionary: public Transliteration::BaseTransliterationDictionary { @@ -162,4 +159,4 @@ std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Chinese const return result; } -} // namespace Chinese +} // namespace ChineseTranslit diff --git a/src/dict/chinese.hh b/src/dict/transliteration/chinese.hh similarity index 84% rename from src/dict/chinese.hh rename to src/dict/transliteration/chinese.hh index 4c4fcc64..f0a90e02 100644 --- a/src/dict/chinese.hh +++ b/src/dict/transliteration/chinese.hh @@ -3,12 +3,10 @@ #pragma once -#include -#include "config.hh" #include "dictionary.hh" /// Chinese character conversion support. -namespace Chinese { +namespace ChineseTranslit { std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Chinese const & ); } diff --git a/src/dict/customtransliteration.cc b/src/dict/transliteration/custom.cc similarity index 97% rename from src/dict/customtransliteration.cc rename to src/dict/transliteration/custom.cc index 38a6863a..10bd2c27 100644 --- a/src/dict/customtransliteration.cc +++ b/src/dict/transliteration/custom.cc @@ -1,4 +1,4 @@ -#include "customtransliteration.hh" +#include "custom.hh" #include "dictionary.hh" #include diff --git a/src/dict/customtransliteration.hh b/src/dict/transliteration/custom.hh similarity index 96% rename from src/dict/customtransliteration.hh rename to src/dict/transliteration/custom.hh index e09882c4..0b1badc6 100644 --- a/src/dict/customtransliteration.hh +++ b/src/dict/transliteration/custom.hh @@ -1,7 +1,6 @@ #pragma once -#include #include "transliteration.hh" // Support for Belarusian transliteration diff --git a/src/dict/german.cc b/src/dict/transliteration/german.cc similarity index 100% rename from src/dict/german.cc rename to src/dict/transliteration/german.cc diff --git a/src/dict/german.hh b/src/dict/transliteration/german.hh similarity index 100% rename from src/dict/german.hh rename to src/dict/transliteration/german.hh diff --git a/src/dict/greektranslit.cc b/src/dict/transliteration/greek.cc similarity index 99% rename from src/dict/greektranslit.cc rename to src/dict/transliteration/greek.cc index d6d4dd21..9a990190 100644 --- a/src/dict/greektranslit.cc +++ b/src/dict/transliteration/greek.cc @@ -1,7 +1,7 @@ /* This file is (c) 2010 Jennie Petoumenou * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ -#include "greektranslit.hh" +#include "greek.hh" #include "transliteration.hh" #include diff --git a/src/dict/greektranslit.hh b/src/dict/transliteration/greek.hh similarity index 100% rename from src/dict/greektranslit.hh rename to src/dict/transliteration/greek.hh diff --git a/src/dict/romaji.cc b/src/dict/transliteration/romaji.cc similarity index 99% rename from src/dict/romaji.cc rename to src/dict/transliteration/romaji.cc index 7b129d40..1bf3af29 100644 --- a/src/dict/romaji.cc +++ b/src/dict/transliteration/romaji.cc @@ -1,7 +1,9 @@ #include "romaji.hh" #include -namespace Romaji { +namespace RomajiTranslit { + +using std::vector; class HepburnHiragana: public Transliteration::Table { @@ -375,4 +377,4 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & r ) return result; } -} // namespace Romaji +} // namespace RomajiTranslit diff --git a/src/dict/romaji.hh b/src/dict/transliteration/romaji.hh similarity index 59% rename from src/dict/romaji.hh rename to src/dict/transliteration/romaji.hh index 1469d088..8293799d 100644 --- a/src/dict/romaji.hh +++ b/src/dict/transliteration/romaji.hh @@ -4,12 +4,9 @@ #pragma once #include "transliteration.hh" -#include "config.hh" /// Japanese romanization (Romaji) support. -namespace Romaji { +namespace RomajiTranslit { -using std::vector; - -vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & ); -} // namespace Romaji +std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & ); +} // namespace RomajiTranslit diff --git a/src/dict/russiantranslit.cc b/src/dict/transliteration/russian.cc similarity index 98% rename from src/dict/russiantranslit.cc rename to src/dict/transliteration/russian.cc index e132f8a5..7a1d1a13 100644 --- a/src/dict/russiantranslit.cc +++ b/src/dict/transliteration/russian.cc @@ -1,7 +1,7 @@ /* This file is (c) 2008-2012 Konstantin Isakov * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ -#include "russiantranslit.hh" +#include "russian.hh" #include "transliteration.hh" #include diff --git a/src/dict/russiantranslit.hh b/src/dict/transliteration/russian.hh similarity index 100% rename from src/dict/russiantranslit.hh rename to src/dict/transliteration/russian.hh diff --git a/src/dict/transliteration.cc b/src/dict/transliteration/transliteration.cc similarity index 100% rename from src/dict/transliteration.cc rename to src/dict/transliteration/transliteration.cc diff --git a/src/dict/transliteration.hh b/src/dict/transliteration/transliteration.hh similarity index 100% rename from src/dict/transliteration.hh rename to src/dict/transliteration/transliteration.hh