Crowdin sync, localized setup instructions

This commit is contained in:
M66B
2019-08-05 11:14:28 +02:00
parent 228e6b4dc9
commit 4afc7f659b
47 changed files with 1748 additions and 2 deletions

View File

@@ -14,6 +14,9 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import io.noties.markwon.Markwon;
@@ -50,6 +53,25 @@ public class FragmentDialogMarkdown extends FragmentDialogEx {
@Override
protected Spanned onExecute(Context context, Bundle args) throws Throwable {
String name = args.getString("name");
String[] c = name.split("\\.");
List<String> assets = Arrays.asList(getResources().getAssets().list(""));
String country = Locale.getDefault().getCountry();
String language = Locale.getDefault().getLanguage();
String localized = c[0] + "-" + language + "-" + country + "." + c[1];
Log.i("Checking " + localized);
if (assets.contains(localized))
name = localized;
else {
localized = c[0] + "-" + language + "." + c[1];
Log.i("Checking " + localized);
if (assets.contains(localized))
name = localized;
}
Log.i("Using " + name);
try (InputStream is = context.getAssets().open(name)) {
byte[] buffer = new byte[is.available()];
is.read(buffer);