Strings update

Updating strings
Removed non crowdin strings
Removed the locale wrapper as we do not support in app language changes
This commit is contained in:
ThomasSession
2024-09-12 16:29:27 +10:00
parent d30ff252ab
commit 304679dac6
28 changed files with 48 additions and 698 deletions

View File

@@ -1,40 +0,0 @@
package org.session.libsession.utilities.dynamiclanguage;
import android.app.Activity;
import androidx.annotation.MainThread;
import androidx.core.os.ConfigurationCompat;
import org.session.libsignal.utilities.Log;
import java.util.Locale;
public final class DynamicLanguageActivityHelper {
private static final String TAG = DynamicLanguageActivityHelper.class.getSimpleName();
private static String reentryProtection;
/**
* If the activity isn't in the specified language, it will restart the activity.
*/
@MainThread
public static void recreateIfNotInCorrectLanguage(Activity activity, String language) {
Locale currentActivityLocale = ConfigurationCompat.getLocales(activity.getResources().getConfiguration()).get(0);
Locale selectedLocale = LocaleParser.findBestMatchingLocaleForLanguage(language);
if (currentActivityLocale.equals(selectedLocale)) {
reentryProtection = "";
return;
}
String reentryKey = activity.getClass().getName() + ":" + selectedLocale;
if (!reentryKey.equals(reentryProtection)) {
reentryProtection = reentryKey;
Log.d(TAG, String.format("Activity Locale %s, Selected locale %s, restarting", currentActivityLocale, selectedLocale));
activity.recreate();
} else {
Log.d(TAG, String.format("Skipping recreate as looks like looping, Activity Locale %s, Selected locale %s", currentActivityLocale, selectedLocale));
}
}
}

View File

@@ -1,33 +0,0 @@
package org.session.libsession.utilities.dynamiclanguage;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import java.util.Locale;
/**
* Updates a context with an alternative language.
*/
public final class DynamicLanguageContextWrapper {
public static Context updateContext(Context context, String language) {
final Locale newLocale = LocaleParser.findBestMatchingLocaleForLanguage(language);
Locale.setDefault(newLocale);
final Resources resources = context.getResources();
final Configuration config = resources.getConfiguration();
final Configuration newConfig = copyWithNewLocale(config, newLocale);
resources.updateConfiguration(newConfig, resources.getDisplayMetrics());
return context;
}
private static Configuration copyWithNewLocale(Configuration config, Locale locale) {
final Configuration copy = new Configuration(config);
copy.setLocale(locale);
return copy;
}
}

View File

@@ -1,47 +0,0 @@
package org.session.libsession.utilities.dynamiclanguage;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Locale;
public final class LanguageString {
private LanguageString() { }
/**
* @param languageString String in format language_REGION, e.g. en_US
* @return Locale, or null if cannot parse
*/
@Nullable
public static Locale parseLocale(@Nullable String languageString) {
if (languageString == null || languageString.isEmpty()) {
return null;
}
final Locale locale = createLocale(languageString);
if (!isValid(locale)) {
return null;
} else {
return locale;
}
}
private static Locale createLocale(@NonNull String languageString) {
final String language[] = languageString.split("_");
if (language.length == 2) {
return new Locale(language[0], language[1]);
} else {
return new Locale(language[0]);
}
}
private static boolean isValid(@NonNull Locale locale) {
try {
return locale.getISO3Language() != null && locale.getISO3Country() != null;
} catch (Exception ex) {
return false;
}
}
}

View File

@@ -1,28 +0,0 @@
package org.session.libsession.utilities.dynamiclanguage
import java.util.*
class LocaleParser(val helper: LocaleParserHelperProtocol) {
companion object {
lateinit var shared: LocaleParser
fun configure(helper: LocaleParserHelperProtocol) {
if (Companion::shared.isInitialized) { return }
shared = LocaleParser(helper)
}
/**
* Given a language, gets the best choice from the apps list of supported languages and the
* Systems set of languages.
*/
@JvmStatic
fun findBestMatchingLocaleForLanguage(language: String?): Locale? {
val locale = LanguageString.parseLocale(language)
return if (shared.helper.appSupportsTheExactLocale(locale)) {
locale
} else {
shared.helper.findBestSystemLocale()
}
}
}
}

View File

@@ -1,8 +0,0 @@
package org.session.libsession.utilities.dynamiclanguage
import java.util.Locale
interface LocaleParserHelperProtocol {
fun appSupportsTheExactLocale(locale: Locale?): Boolean
fun findBestSystemLocale(): Locale
}

View File

@@ -146,7 +146,7 @@
<string name="callsIncomingUnknown">Incoming call</string>
<string name="callsMissed">Missed Call</string>
<string name="callsMissedCallFrom">Missed call from {name}</string>
<string name="callsNotificationsRequired">Voice and Video Calls require notifications to be enabled in your device system settings. </string>
<string name="callsNotificationsRequired">Voice and Video Calls require notifications to be enabled in your device system settings.</string>
<string name="callsPermissionsRequired">Call Permissions Required</string>
<string name="callsPermissionsRequiredDescription">You can enable the \"Voice and Video Calls\" permission in Privacy Settings.</string>
<string name="callsReconnecting">Reconnecting…</string>
@@ -436,7 +436,7 @@
<string name="groupNameEnter">Enter a group name</string>
<string name="groupNameEnterPlease">Please enter a group name.</string>
<string name="groupNameEnterShorter">Please enter a shorter group name.</string>
<string name="groupNameNew">Group name is now {group_name}. </string>
<string name="groupNameNew">Group name is now {group_name}.</string>
<string name="groupNameUpdated">Group name updated.</string>
<string name="groupNoMessages">You have no messages from <b>{group_name}</b>. Send a message to start the conversation!</string>
<string name="groupOnlyAdmin">You are the only admin in <b>{group_name}</b>.\n\nGroup members and settings cannot be changed without an admin.</string>
@@ -692,7 +692,7 @@
<string name="permissionsMicrophoneAccessRequiredIos">{app_name} needs microphone access to make calls and record audio messages.</string>
<string name="permissionsMicrophoneDescription">Allow access to microphone.</string>
<string name="permissionsMusicAudio">{app_name} needs music and audio access in order to send files, music and audio.</string>
<string name="permissionsRequired">Permission required</string>
<string name="permissionsRequired">Permission Required</string>
<string name="permissionsStorageDenied">{app_name} needs photo library access so you can send photos and videos, but it has been permanently denied. Tap Settings -&gt; Permissions, and turn \"Photos and videos\" on.</string>
<string name="permissionsStorageDeniedLegacy">{app_name} needs storage access so you can send and save attachments. Tap Settings -&gt; Permissions, and turn \"Storage\" on.</string>
<string name="permissionsStorageSave">{app_name} needs storage access to save attachments and media.</string>
@@ -814,7 +814,7 @@
<string name="updateError">Cannot Update</string>
<string name="updateErrorDescription">{app_name} failed to update. Please go to {session_download_url} and install the new version manually, then contact our Help Center to let us know about this problem.</string>
<string name="updateNewVersion">A new version of {app_name} is available, tap to update</string>
<string name="updateNewVersionDescription">A new version of {app_name} is available. </string>
<string name="updateNewVersionDescription">A new version of {app_name} is available.</string>
<string name="updateReleaseNotes">Go to Release Notes</string>
<string name="updateSession">{app_name} Update</string>
<string name="updateVersion">Version {version}</string>