Skip to content

Commit

Permalink
Update the list of languages from opensubtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
smplayer-dev committed Dec 13, 2023
1 parent 882b8d4 commit 71c48a5
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 20 deletions.
28 changes: 9 additions & 19 deletions src/findsubtitles/findsubtitleswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ void FindSubtitlesWindow::retranslateStrings() {
while (i1.hasNext()) {
i1.next();
if (i1.key() == "es") {
language_filter->addItem( tr("Spanish") + " (es,sp,ea)", "es|sp|ea");
language_filter->addItem( tr("Spanish") + " (es,sp,ea)", "ea,es,sp");
}
else
if (i1.key() == "pt") {
language_filter->addItem( tr("Portuguese") + " (pt,pb,pm)", "pt|pb|pm");
language_filter->addItem( tr("Portuguese") + " (pt-pt,pt-br,pm)", "pm,pt-pb,pt-pt");
}
else {
language_filter->addItem( i1.value() + " (" + i1.key() + ")", i1.key() );
Expand All @@ -256,24 +256,12 @@ void FindSubtitlesWindow::retranslateStrings() {
language_filter->insertSeparator(language_filter->count());
#endif

QMap<QString,QString> l2 = Languages::list();
QMapIterator<QString, QString> i2(l2);
while (i2.hasNext()) {
i2.next();
if (language_filter->findData(i2.key()) == -1) {
if (i2.key() == "es") {
language_filter->addItem( tr("Spanish - Spain") + " (sp)", "sp");
language_filter->addItem( tr("Spanish - Latin America") + " (ea)", "ea");
}
else
if (i2.key() == "pt") {
language_filter->addItem( tr("Portuguese - Brasil") + " (pb)", "pb");
}
else {
language_filter->addItem( i2.value() + " (" + i2.key() + ")", i2.key() );
}
}
QMap<QString,QString> l2 = Languages::os_languages();
foreach (QString key, l2.keys()) {
QString lang = l2.value(key);
language_filter->addItem( lang + " (" + key + ")", key );
}

//language_filter->model()->sort(0);
language_filter->insertItem( 0, tr("All"), "" );
#if QT_VERSION >= 0x040400
Expand Down Expand Up @@ -375,9 +363,11 @@ void FindSubtitlesWindow::applyFilter(const QString & filter) {
}

void FindSubtitlesWindow::applyCurrentFilter() {
#if 0
//proxy_model->setFilterWildcard(language_filter->currentText());
QString filter = language_filter->itemData( language_filter->currentIndex() ).toString();
applyFilter(filter);
#endif
}

void FindSubtitlesWindow::setLanguage(const QString & lang) {
Expand Down
3 changes: 2 additions & 1 deletion src/findsubtitles/osclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ void OSClient::search(const QString & hash, qint64 file_size, QString search_ter

qRestAPI::Parameters par;
//par["ai_translated"] = "exclude";
par["order_by"] = "upload_date";

if (!languages.isEmpty()) {
par["languages"] = languages.replace('|', ',');
par["languages"] = languages;
}

search_term = search_term.replace(" ", "+").toLower();
Expand Down
106 changes: 106 additions & 0 deletions src/languages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,110 @@ QMap<QString,QString> Languages::enca() {
return l;
}

QMap<QString,QString> Languages::os_languages() {
QMap<QString,QString> l;
l["af"] = tr("Afrikaans");
l["be"] = tr("Belarusian");
l["my"] = tr("Burmese");
l["ab"] = tr("Abkhazian");
l["ar"] = tr("Arabic");
l["hy"] = tr("Armenian");
l["as"] = tr("Assamese");
l["at"] = tr("Asturian");
l["eu"] = tr("Basque");
l["bn"] = tr("Bengali");
l["br"] = tr("Breton");
l["bg"] = tr("Bulgarian");
l["ca"] = tr("Catalan");
l["zh-cn"] = tr("Chinese (simplified)");
l["fr"] = tr("French");
l["ka"] = tr("Georgian");
l["de"] = tr("German");
l["gd"] = tr("Gaelic");
l["ga"] = tr("Irish");
l["gl"] = tr("Galician");
l["el"] = tr("Greek");
l["he"] = tr("Hebrew");
l["hi"] = tr("Hindi");
l["hr"] = tr("Croatian");
l["hu"] = tr("Hungarian");
l["ig"] = tr("Igbo");
l["is"] = tr("Icelandic");
l["ia"] = tr("Interlingua");
l["kk"] = tr("Kazakh");
l["lv"] = tr("Latvian");
l["lt"] = tr("Lithuanian");
l["ml"] = tr("Malayalam");
l["it"] = tr("Italian");
l["ja"] = tr("Japanese");
l["km"] = tr("Khmer");
l["ko"] = tr("Korean");
l["ku"] = tr("Kurdish");
l["mk"] = tr("Macedonian");
l["mr"] = tr("Marathi");
l["nv"] = tr("Navajo");
l["no"] = tr("Norwegian");
l["oc"] = tr("Occitan");
l["fa"] = tr("Persian");
l["pl"] = tr("Polish");
l["pt-pt"] = tr("Portuguese");
l["ps"] = tr("Pushto");
l["ru"] = tr("Russian");
l["sr"] = tr("Serbian");
l["sk"] = tr("Slovak");
l["sl"] = tr("Slovenian");
l["sy"] = tr("Syriac");
l["ta"] = tr("Tamil");
l["me"] = tr("Montenegrin");
l["ze"] = tr("Chinese bilingual");
l["sd"] = tr("Sindhi");
l["es"] = tr("Spanish");
l["sw"] = tr("Swahili");
l["sv"] = tr("Swedish");
l["tt"] = tr("Tatar");
l["te"] = tr("Telugu");
l["th"] = tr("Thai");
l["tk"] = tr("Turkmen");
l["tr"] = tr("Turkish");
l["uk"] = tr("Ukrainian");
l["uz"] = tr("Uzbek");
l["vi"] = tr("Vietnamese");
l["cy"] = tr("Welsh");
l["ro"] = tr("Romanian");
l["pt-br"] = tr("Portuguese (BR)");
l["zh-tw"] = tr("Chinese (traditional)");
l["sq"] = tr("Albanian");
l["an"] = tr("Aragonese");
l["az"] = tr("Azerbaijani");
l["bs"] = tr("Bosnian");
l["cs"] = tr("Czech");
l["da"] = tr("Danish");
l["nl"] = tr("Dutch");
l["en"] = tr("English");
l["eo"] = tr("Esperanto");
l["et"] = tr("Estonian");
l["fi"] = tr("Finnish");
l["id"] = tr("Indonesian");
l["kn"] = tr("Kannada");
l["lb"] = tr("Luxembourgish");
l["ms"] = tr("Malay");
l["ma"] = tr("Manipuri");
l["mn"] = tr("Mongolian");
l["ne"] = tr("Nepali");
l["or"] = tr("Odia");
l["si"] = tr("Sinhalese");
l["se"] = tr("Northern Sami");
l["so"] = tr("Somali");
l["tl"] = tr("Tagalog");
l["ur"] = tr("Urdu");
l["pm"] = tr("Portuguese (MZ)");
l["ea"] = tr("Spanish (LA)");
l["ex"] = tr("Extremaduran");
l["pr"] = tr("Dari");
l["sp"] = tr("Spanish (EU)");
l["sx"] = tr("Santali");
l["tp"] = tr("Toki Pona");
return l;
}

#include "moc_languages.cpp"
2 changes: 2 additions & 0 deletions src/languages.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Languages : public QObject
static QMap<QString,QString> encodings();

static QMap<QString,QString> enca();

static QMap<QString,QString> os_languages();
};

#endif
Expand Down

0 comments on commit 71c48a5

Please sign in to comment.