diff --git a/goldendict.pro b/goldendict.pro
index f5f4e963..63cae269 100644
--- a/goldendict.pro
+++ b/goldendict.pro
@@ -321,6 +321,7 @@ HEADERS += \
src/dict/belarusiantranslit.hh \
src/dict/bgl.hh \
src/dict/bgl_babylon.hh \
+ src/dict/customtransliteration.hh \
src/dict/dictdfiles.hh \
src/dict/dictionary.hh \
src/dict/dictserver.hh \
@@ -444,6 +445,7 @@ SOURCES += \
src/dict/belarusiantranslit.cc \
src/dict/bgl.cc \
src/dict/bgl_babylon.cc \
+ src/dict/customtransliteration.cpp \
src/dict/dictdfiles.cc \
src/dict/dictionary.cc \
src/dict/dictserver.cc \
diff --git a/icons/custom_trans.svg b/icons/custom_trans.svg
new file mode 100644
index 00000000..43a3b3f9
--- /dev/null
+++ b/icons/custom_trans.svg
@@ -0,0 +1,78 @@
+
+
+
+
diff --git a/locale/crowdin.ts b/locale/crowdin.ts
index 2dec7456..81cd28c8 100644
--- a/locale/crowdin.ts
+++ b/locale/crowdin.ts
@@ -5264,6 +5264,21 @@ based on English phonology
日语的平假名
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources.qrc b/resources.qrc
index afd12cd0..282ad1e1 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -88,5 +88,6 @@
icons/mdict-bg.png
icons/old-arrow.png
icons/old-downarrow.png
+ icons/custom_trans.svg
diff --git a/src/config.cc b/src/config.cc
index cd380265..dd7fe1df 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -3,20 +3,19 @@
#include "config.hh"
#include "folding.hh"
-#include "wstring_qt.hh"
#include
#include
#include
#include "gddebug.hh"
-#include
-
#ifdef Q_OS_WIN32
-#include "shlobj.h"
+ //this is a windows header file.
+ #include
#endif
+#include
+
#include "atomic_rename.hh"
-#include "utils.hh"
#include
@@ -699,6 +698,14 @@ Class load()
applyBoolOption( c.transliteration.romaji.enableHiragana, romaji.namedItem( "enableHiragana" ) );
applyBoolOption( c.transliteration.romaji.enableKatakana, romaji.namedItem( "enableKatakana" ) );
}
+
+ QDomNode customtrans = transliteration.namedItem( "customtrans" );
+
+ if ( !customtrans.isNull() )
+ {
+ applyBoolOption( c.transliteration.customTrans.enable, customtrans.namedItem( "enable" ) );
+ c.transliteration.customTrans.context = customtrans.namedItem( "context" ).toElement().text() ;
+ }
}
QDomNode lingua = root.namedItem("lingua");
@@ -1478,6 +1485,18 @@ void save( Class const & c )
opt = dd.createElement( "enableKatakana" );
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableKatakana ? "1":"0" ) );
romaji.appendChild( opt );
+
+ //custom transliteration
+ QDomElement customtrans = dd.createElement( "customtrans" );
+ transliteration.appendChild( customtrans );
+
+ opt = dd.createElement( "enable" );
+ opt.appendChild( dd.createTextNode( c.transliteration.customTrans.enable ? "1":"0" ) );
+ customtrans.appendChild( opt );
+
+ opt = dd.createElement( "context" );
+ opt.appendChild( dd.createTextNode( c.transliteration.customTrans.context ) );
+ customtrans.appendChild( opt );
}
{
diff --git a/src/config.hh b/src/config.hh
index 0cfa06b7..3fe42d97 100644
--- a/src/config.hh
+++ b/src/config.hh
@@ -15,10 +15,6 @@
#include "ex.hh"
#include
-#ifdef Q_OS_WIN
-#include
-#endif
-
/// GoldenDict's configuration
namespace Config {
@@ -508,6 +504,23 @@ struct Chinese
};
+struct CustomTrans
+{
+ bool enable = false;
+
+ QString context;
+
+ bool operator==( CustomTrans const & other ) const
+ {
+ return enable == other.enable && context == other.context;
+ }
+
+ bool operator!=( CustomTrans const & other ) const
+ {
+ return !operator==( other );
+ }
+};
+
/// Romaji transliteration configuration
struct Romaji
{
@@ -540,20 +553,24 @@ struct Transliteration
bool enableGermanTransliteration;
bool enableGreekTransliteration;
bool enableBelarusianTransliteration;
+
+ CustomTrans customTrans;
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
Chinese chinese;
#endif
Romaji romaji;
- bool operator == ( Transliteration const & other ) const
- { return enableRussianTransliteration == other.enableRussianTransliteration &&
- enableGermanTransliteration == other.enableGermanTransliteration &&
- enableGreekTransliteration == other.enableGreekTransliteration &&
- enableBelarusianTransliteration == other.enableBelarusianTransliteration &&
+ bool operator==( Transliteration const & other ) const
+ {
+ return enableRussianTransliteration == other.enableRussianTransliteration
+ && enableGermanTransliteration == other.enableGermanTransliteration
+ && enableGreekTransliteration == other.enableGreekTransliteration
+ && enableBelarusianTransliteration == other.enableBelarusianTransliteration
+ && customTrans == other.customTrans &&
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
- chinese == other.chinese &&
+ chinese == other.chinese &&
#endif
- romaji == other.romaji;
+ romaji == other.romaji;
}
bool operator != ( Transliteration const & other ) const
diff --git a/src/dict/customtransliteration.cpp b/src/dict/customtransliteration.cpp
new file mode 100644
index 00000000..0487a6b2
--- /dev/null
+++ b/src/dict/customtransliteration.cpp
@@ -0,0 +1,58 @@
+#include "customtransliteration.hh"
+#include "dictionary.hh"
+
+namespace CustomTranslit {
+
+CustomTransTable::CustomTransTable( const QString & content_ )
+{
+ parse( content_ );
+}
+
+void CustomTransTable::parse( const QString & content )
+{
+ QTextStream stream( content.toUtf8() );
+ while ( !stream.atEnd() ) {
+ auto line = stream.readLine();
+ auto hashPos = line.indexOf( '#' );
+ if ( hashPos > -1 ) {
+ line = line.left( hashPos );
+ }
+
+ auto parts = line.split( ';', Qt::SkipEmptyParts );
+ if ( parts.size() != 2 ) {
+ continue;
+ }
+ //check part length, normally they should all with length<=2
+ bool validState = true;
+ for ( auto & part : parts ) {
+ if ( part.trimmed().length() > 2 ) {
+ validState = false;
+ break;
+ }
+ }
+
+ if ( !validState ) {
+ continue;
+ }
+
+ ins(parts[0].toUtf8(),parts[1].toUtf8());
+ }
+}
+
+std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::CustomTrans const & cusTran )
+{
+
+ std::vector< sptr< Dictionary::Class > > result;
+
+ if(cusTran.enable){
+ static CustomTranslit::CustomTransTable t0(cusTran.context);
+
+ result.push_back( std::make_shared( "custom-transliteration-dict",
+ QCoreApplication::translate( "CustomTranslit", "custom transliteration" ).toUtf8().data(),
+ QIcon( ":/icons/custom_trans.svg" ), t0, false ) );
+ }
+ return result;
+
+}
+
+}
diff --git a/src/dict/customtransliteration.hh b/src/dict/customtransliteration.hh
new file mode 100644
index 00000000..484815a5
--- /dev/null
+++ b/src/dict/customtransliteration.hh
@@ -0,0 +1,26 @@
+#ifndef CUSTOMTRANSLITERATION_HH
+ #define CUSTOMTRANSLITERATION_HH
+
+
+#include
+#include "transliteration.hh"
+
+// Support for Belarusian transliteration
+namespace CustomTranslit {
+
+class CustomTransTable: public Transliteration::Table
+{
+public:
+ CustomTransTable() = default;
+
+ explicit CustomTransTable( const QString & content );
+
+private:
+ void parse( const QString & content );
+};
+
+
+std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::CustomTrans const & );
+
+}
+#endif // CUSTOMTRANSLITERATION_HH
diff --git a/src/dict/loaddictionaries.cc b/src/dict/loaddictionaries.cc
index 2911b696..f82c6861 100644
--- a/src/dict/loaddictionaries.cc
+++ b/src/dict/loaddictionaries.cc
@@ -12,6 +12,7 @@
#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"
@@ -212,7 +213,7 @@ void loadDictionaries( QWidget * parent, bool showInitially,
#endif
addDicts(Romaji::makeDictionaries( cfg.transliteration.romaji ));
-
+ addDicts(CustomTranslit::makeDictionaries( cfg.transliteration.customTrans));
// Make Russian transliteration
if ( cfg.transliteration.enableRussianTransliteration )
diff --git a/src/dict/romaji.hh b/src/dict/romaji.hh
index 58d08669..1a49a061 100644
--- a/src/dict/romaji.hh
+++ b/src/dict/romaji.hh
@@ -12,9 +12,7 @@ namespace Romaji {
using std::vector;
-vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & )
- ;
-
+vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & );
}
#endif
diff --git a/src/dict/sources.cc b/src/dict/sources.cc
index e4c5ca67..dc15281b 100644
--- a/src/dict/sources.cc
+++ b/src/dict/sources.cc
@@ -113,6 +113,9 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg):
ui.enableHiragana->setChecked( trs.romaji.enableHiragana );
ui.enableKatakana->setChecked( trs.romaji.enableKatakana );
+ ui.enableCustomTransliteration->setChecked( trs.customTrans.enable );
+ ui.customTransliteration->setPlainText( trs.customTrans.context );
+
ui.linguaEnabled->setChecked(lingua.enable);
ui.linguaLangCode->setText(lingua.languageCodes);
@@ -369,6 +372,9 @@ Config::Transliteration Sources::getTransliteration() const
tr.romaji.enableHiragana = ui.enableHiragana->isChecked();
tr.romaji.enableKatakana = ui.enableKatakana->isChecked();
+ tr.customTrans.enable = ui.enableCustomTransliteration->isChecked();
+ tr.customTrans.context = ui.customTransliteration->toPlainText();
+
return tr;
}
diff --git a/src/ui/preferences.ui b/src/ui/preferences.ui
index 48a35d34..e3c9c83f 100644
--- a/src/ui/preferences.ui
+++ b/src/ui/preferences.ui
@@ -1502,19 +1502,6 @@ download page.
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
@@ -1526,8 +1513,17 @@ download page.
-
+
+ 0
+
-
+
+
+ 0
+ 0
+
+
Favorites saving interval. If set to 0 Favorites will be saved only during exit.
@@ -1545,6 +1541,12 @@ download page.
-
+
+
+ 0
+ 0
+
+
minutes
@@ -1563,7 +1565,7 @@ download page.
-
-
+
Qt::Vertical
diff --git a/src/ui/sources.ui b/src/ui/sources.ui
index 98dd49e7..54d88eca 100644
--- a/src/ui/sources.ui
+++ b/src/ui/sources.ui
@@ -33,7 +33,7 @@
-
+
:/icons/folders.svg:/icons/folders.svg
@@ -96,7 +96,7 @@
-
+
:/icons/folder-sound.svg:/icons/folder-sound.svg
@@ -152,7 +152,7 @@
-
+
:/icons/icon32_hunspell.png:/icons/icon32_hunspell.png
@@ -220,7 +220,7 @@ of the appropriate groups to use them.
-
+
:/icons/icon32_wiki.png:/icons/icon32_wiki.png
@@ -279,7 +279,7 @@ of the appropriate groups to use them.
-
+
:/icons/internet.svg:/icons/internet.svg
@@ -343,7 +343,7 @@ of the appropriate groups to use them.
-
+
:/icons/network.svg:/icons/network.svg
@@ -399,7 +399,7 @@ of the appropriate groups to use them.
-
+
:/icons/programs.svg:/icons/programs.svg
@@ -458,7 +458,7 @@ of the appropriate groups to use them.
-
+
:/icons/lingualibre.svg:/icons/lingualibre.svg
@@ -526,7 +526,7 @@ Full list of availiable languages can be found <a href="https://linguali
-
+
:/icons/forvo.png:/icons/forvo.png
@@ -674,7 +674,7 @@ Full list of availiable languages can be found <a href="https://linguali
-
+
:/icons/transliteration.png:/icons/transliteration.png
@@ -692,7 +692,7 @@ Full list of availiable languages can be found <a href="https://linguali
Greek transliteration
-
+
:/flags/gr.png:/flags/gr.png
@@ -703,7 +703,7 @@ Full list of availiable languages can be found <a href="https://linguali
Russian transliteration
-
+
:/flags/ru.png:/flags/ru.png
@@ -714,7 +714,7 @@ Full list of availiable languages can be found <a href="https://linguali
German transliteration
-
+
:/flags/de.png:/flags/de.png
@@ -725,7 +725,7 @@ Full list of availiable languages can be found <a href="https://linguali
Belarusian transliteration
-
+
:/flags/by.png:/flags/by.png
@@ -827,6 +827,39 @@ Not implemented yet in GoldenDict.
+ -
+
+
-
+
+
+ Custom transliteration
+
+
+ true
+
+
+
-
+
+
+ This only applied in search phrase, with each line represent a transliteration,semicolon seperated. For example, ae;æ,users can input ae to represent æ in the target word.
+
+
+ true
+
+
+
+ -
+
+
+ ae;æ #this is an example
+
+
+
+
+
+
+
+
@@ -857,6 +890,9 @@ Not implemented yet in GoldenDict.
removeSoundDir
paths
-
+
+
+
+