| 1361 | } |
| 1362 | |
| 1363 | void CustomLangPack::fetchFinished() { |
| 1364 | if (!_chkReply) return; |
| 1365 | |
| 1366 | QString langPackBaseId = Lang::GetInstance().baseId(); |
| 1367 | QString langPackId = Lang::GetInstance().id(); |
| 1368 | auto statusCode = _chkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); |
| 1369 | |
| 1370 | if (statusCode == 404 && !langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) { |
| 1371 | LOG(("64Gram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId)); |
| 1372 | needFallback = true; |
| 1373 | _chkReply->disconnect(); |
| 1374 | fetchCustomLangPack("", langPackBaseId); |
| 1375 | } |
| 1376 | else { |
| 1377 | QByteArray result = _chkReply->readAll().trimmed(); |
| 1378 | QJsonParseError error{}; |
| 1379 | QJsonDocument str = QJsonDocument::fromJson(result, &error); |
| 1380 | if (error.error == QJsonParseError::NoError) { |
| 1381 | parseLangFile(str); |
| 1382 | } else { |
| 1383 | LOG(("Incorrect JSON File. Fallback to default language: English...")); |
| 1384 | loadDefaultLangFile(); |
| 1385 | } |
| 1386 | |
| 1387 | _chkReply = nullptr; |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | void CustomLangPack::fetchError(QNetworkReply::NetworkError e) { |
| 1392 | LOG(("Network error: %1").arg(e)); |