Skip to content

Commit

Permalink
Set the backend language on app startup
Browse files Browse the repository at this point in the history
  • Loading branch information
dae authored and mikehardy committed Jun 29, 2022
1 parent 55a3800 commit 514b544
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
import com.ichi2.anki.analytics.UsageAnalytics;
import com.ichi2.utils.Permissions;

import net.ankiweb.rsdroid.BackendFactory;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -297,6 +301,8 @@ public static Context updateContextWithLanguage(@NonNull Context remoteContext)
preferences = getSharedPrefs(remoteContext);
}
Configuration langConfig = getLanguageConfig(remoteContext.getResources().getConfiguration(), preferences);
// TODO: support fallback languages (backend already automatically adds English to the end)
BackendFactory.INSTANCE.setDefaultLanguagesFromLocales(Arrays.asList(langConfig.locale));
return remoteContext.createConfigurationContext(langConfig);
} catch (Exception e) {
Timber.e(e, "failed to update context with new language");
Expand Down
2 changes: 2 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ open class Collection constructor(
*/
val backend: Backend
) : CollectionGetter {
/** Access backend translations */
val tr = backend.tr

@get:JvmName("isDbClosed")
val dbClosed: Boolean
Expand Down

0 comments on commit 514b544

Please sign in to comment.