mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-04-24 23:18:43 +02:00
Fix crashes
This commit is contained in:
parent
8548777c50
commit
3be0cd727f
@ -543,10 +543,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String lang = null;
|
String lang = Locale.getDefault().getLanguage();
|
||||||
if (PeertubeInformation.langueMapped.containsKey(Locale.getDefault().getLanguage()))
|
if( lang.contains("-")) {
|
||||||
lang = PeertubeInformation.langueMapped.get(Locale.getDefault().getLanguage());
|
if( !lang.split("-")[0].trim().toLowerCase().startsWith("zh")){
|
||||||
|
lang = lang.split("-")[0];
|
||||||
|
}else {
|
||||||
|
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
Call<Map<String, String>> translations = initTranslation().getTranslations(lang);
|
Call<Map<String, String>> translations = initTranslation().getTranslations(lang);
|
||||||
try {
|
try {
|
||||||
Response<Map<String, String>> response = translations.execute();
|
Response<Map<String, String>> response = translations.execute();
|
||||||
@ -556,7 +560,23 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.errorBody().string());
|
translations = initTranslation().getTranslations("en");
|
||||||
|
try {
|
||||||
|
response = translations.execute();
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
peertubeInformation.setTranslations(response.body());
|
||||||
|
} else {
|
||||||
|
error = new Error();
|
||||||
|
error.setStatusCode(response.code());
|
||||||
|
if (response.errorBody() != null) {
|
||||||
|
error.setError(response.errorBody().string());
|
||||||
|
} else {
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
|
@ -14,33 +14,11 @@ package app.fedilab.fedilabtube.client.entities;
|
|||||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class PeertubeInformation {
|
public class PeertubeInformation {
|
||||||
|
|
||||||
|
|
||||||
public static final Map<String, String> langueMapped;
|
|
||||||
|
|
||||||
static {
|
|
||||||
Map<String, String> aMap = new LinkedHashMap<>();
|
|
||||||
aMap.put("ca", "ca-ES");
|
|
||||||
aMap.put("de", "de-DE");
|
|
||||||
aMap.put("en", "en-US");
|
|
||||||
aMap.put("es", "es-ES");
|
|
||||||
aMap.put("eo", "eo");
|
|
||||||
aMap.put("eu", "eu-ES");
|
|
||||||
aMap.put("fr", "fr-FR");
|
|
||||||
aMap.put("oc", "oc");
|
|
||||||
aMap.put("pt", "pt-BR");
|
|
||||||
aMap.put("sv", "sv-SE");
|
|
||||||
aMap.put("cs", "cs-CZ");
|
|
||||||
aMap.put("zh-CN", "zh-Hans-CN");
|
|
||||||
aMap.put("zh-TW", "zh-Hans-TW");
|
|
||||||
langueMapped = aMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Integer, String> categories;
|
private Map<Integer, String> categories;
|
||||||
private Map<String, String> languages;
|
private Map<String, String> languages;
|
||||||
private Map<Integer, String> licences;
|
private Map<Integer, String> licences;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user