fix: forvo has no free plan now fix the apikey tooltip

in order to use forvo pronounciation ,an api key has to be aquired.
This commit is contained in:
Xiao YiFang 2022-11-18 20:13:24 +08:00
parent 3b96b468a9
commit cdc0fe07e0
3 changed files with 18 additions and 18 deletions

View file

@ -79,16 +79,18 @@ sptr< DataRequest > ForvoDictionary::getArticle( wstring const & word,
wstring const &, bool ) wstring const &, bool )
{ {
if ( word.size() > 80 ) if ( word.size() > 80 || apiKey.isEmpty() )
{ {
// Don't make excessively large queries -- they're fruitless anyway // Don't make excessively large queries -- they're fruitless anyway
return new DataRequestInstant( false ); return new DataRequestInstant( false );
} }
else else
{
return new ForvoArticleRequest( word, alts, apiKey, languageCode, getId(), return new ForvoArticleRequest( word, alts, apiKey, languageCode, getId(),
netMgr ); netMgr );
} }
}
void ForvoDictionary::loadIcon() noexcept void ForvoDictionary::loadIcon() noexcept
{ {
@ -130,17 +132,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr,
{ {
gdDebug( "Forvo: requesting article %s\n", gd::toQString( str ).toUtf8().data() ); gdDebug( "Forvo: requesting article %s\n", gd::toQString( str ).toUtf8().data() );
QString key; QString key = apiKey;
if ( apiKey.simplified().isEmpty() )
{
// Use the default api key. That's the key I have just registered myself.
// It has a limit of 1000 requests a day, and may also get banned in the
// future. Can't do much about it. Get your own key, it is simple.
key = "5efa5d045a16d10ad9c4705bd5d8e56a";
}
else
key = apiKey;
QUrl reqUrl = QUrl::fromEncoded( QUrl reqUrl = QUrl::fromEncoded(
QString( "https://apifree.forvo.com" QString( "https://apifree.forvo.com"
@ -351,7 +343,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
{ {
vector< sptr< Dictionary::Class > > result; vector< sptr< Dictionary::Class > > result;
if ( forvo.enable ) if ( forvo.enable && !forvo.apiKey.isEmpty())
{ {
QStringList codes = forvo.languageCodes.split( ',', Qt::SkipEmptyParts ); QStringList codes = forvo.languageCodes.split( ',', Qt::SkipEmptyParts );

View file

@ -4735,7 +4735,17 @@ GoldenDict 尚不支持此方案。</translation>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../sources.ui" line="753"/> <location filename="../sources.ui" line="511"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use of Forvo currently requires an API key, register on the site to get your own key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>使 Forvo API key key.</translation>
</message>
<message>
<location filename="../sources.ui" line="534"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Get your own key &lt;a href=&quot;http://api.forvo.com/key/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;a href=&quot;http://api.forvo.com/key/&quot;&gt;这里&lt;/a&gt;获取自己的API Key。</translation>
</message>
<message>
<location filename="../sources.ui" line="689"/>
<source>The most widely used method of transcription of Japanese, <source>The most widely used method of transcription of Japanese,
based on English phonology</source> based on English phonology</source>
<translation></translation> <translation></translation>

View file

@ -508,9 +508,7 @@ of the appropriate groups to use them.</string>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="forvoApiKey"> <widget class="QLineEdit" name="forvoApiKey">
<property name="toolTip"> <property name="toolTip">
<string>Use of Forvo currently requires an API key. Leave this field <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use of Forvo currently requires an API key, register on the site to get your own key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
blank to use the default key, which may become unavailable
in the future, or register on the site to get your own key.</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -533,7 +531,7 @@ in the future, or register on the site to get your own key.</string>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
<property name="text"> <property name="text">
<string>Get your own key &lt;a href=&quot;http://api.forvo.com/key/&quot;&gt;here&lt;/a&gt;, or leave blank to use the default one.</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Get your own key &lt;a href=&quot;http://api.forvo.com/key/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>false</bool> <bool>false</bool>