Localize strings

This commit is contained in:
Mygod
2020-07-04 04:34:58 +08:00
parent 5e5016b059
commit 46d0544df2
5 changed files with 27 additions and 15 deletions

View File

@@ -165,23 +165,25 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
override val title get() = parent.getString(R.string.tethering_manage_wifi)
override val tetherType get() = TetherType.WIFI
override val type get() = VIEW_TYPE_WIFI
override val text get() = listOfNotNull(failureReason?.let { WifiApManager.failureReasonLookup(it) },
override val text get() = listOfNotNull(failureReason?.let { WifiApManager.failureReasonLookup(it) }, baseError,
if (frequency != 0 || bandwidth != WifiApManager.CHANNEL_WIDTH_INVALID) {
"$frequency MHz, channel ${SoftApConfigurationCompat.frequencyToChannel(frequency)}, width " +
WifiApManager.channelWidthLookup(bandwidth, true)
parent.getString(R.string.tethering_manage_wifi_info, frequency,
SoftApConfigurationCompat.frequencyToChannel(frequency),
WifiApManager.channelWidthLookup(bandwidth, true))
} else null,
capability?.let { (maxSupportedClients, supportedFeatures) ->
"${numClients ?: "?"}/$maxSupportedClients clients connected\nSupported features: " + sequence {
app.getString(R.string.tethering_manage_wifi_capabilities, numClients ?: "?",
maxSupportedClients, sequence {
var features = supportedFeatures
if (features == 0L) yield("None") else while (features != 0L) {
if (features == 0L) yield(parent.getString(R.string.tethering_manage_wifi_no_features))
else while (features != 0L) {
@OptIn(ExperimentalStdlibApi::class)
val bit = features.takeLowestOneBit()
yield(WifiApManager.featureLookup(bit, true))
features = features and bit.inv()
}
}.joinToString()
},
baseError).joinToString("\n")
}.joinToString())
}).joinToString("\n")
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_WIFI, true, this)
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_WIFI, this::onException)

View File

@@ -44,7 +44,7 @@ enum class TetherType(@DrawableRes val icon: Int) {
private fun Pair<String?, Resources>.getRegexs(name: String) = second.getIdentifier(name, "array", first).let {
if (it == 0) {
Timber.i("$name is empty")
if (name == "config_tether_wigig_regexs") Timber.i("$name is empty") else Timber.w(Exception(name))
emptyList()
} else second.getStringArray(it).filterNotNull().map { it.toPattern() }
}

View File

@@ -148,7 +148,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
if (!arg.readOnly) dialogView.password.addTextChangedListener(this@WifiApDialogFragment)
if (!arg.p2pMode && Build.VERSION.SDK_INT < 28) dialogView.autoShutdown.isGone = true
if (arg.p2pMode || Build.VERSION.SDK_INT >= 30) {
dialogView.timeoutWrapper.helperText = "Default timeout: ${TetherTimeoutMonitor.defaultTimeout}ms"
dialogView.timeoutWrapper.helperText = getString(R.string.wifi_hotspot_timeout_default,
TetherTimeoutMonitor.defaultTimeout)
if (!arg.readOnly) dialogView.timeout.addTextChangedListener(this@WifiApDialogFragment)
} else dialogView.timeoutWrapper.isGone = true
if (Build.VERSION.SDK_INT >= 23 || arg.p2pMode) dialogView.band.apply {

View File

@@ -99,13 +99,13 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
style="@style/wifi_item_label"
android:text="Turn off hotspot automatically when no devices are connected"/>
android:text="@string/wifi_hotspot_auto_off"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/timeout_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:hint="Inactive timeout"
android:hint="@string/wifi_hotspot_timeout"
app:counterEnabled="true"
app:counterMaxLength="19"
app:errorEnabled="true"
@@ -143,7 +143,7 @@
android:layout_marginTop="8dip"
app:counterEnabled="true"
app:counterMaxLength="17"
android:hint="BSSID">
android:hint="@string/wifi_advanced_mac_address_title">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/bssid"
android:layout_width="match_parent"

View File

@@ -10,6 +10,7 @@
* @string/wifi_ap_choose_auto
* @string/wifi_ap_choose_2G
* @string/wifi_ap_choose_5G
* @string/wifi_advanced_mac_address_title
* @string/wifi_hidden_network
* https://android.googlesource.com/platform/frameworks/base/+/f41fdc9/packages/SystemUI/res/values/strings.xml#874
* @plurals/quick_settings_hotspot_secondary_label_num_devices
@@ -66,6 +67,9 @@
<string name="tethering_manage_ethernet">Ethernet tethering</string>
<string name="tethering_manage_ncm">USB tethering (NCM)</string>
<string name="tethering_manage_wigig">WiGig tethering</string>
<string name="tethering_manage_wifi_info">%1$d MHz, channel %2$d, width %3$s</string>
<string name="tethering_manage_wifi_capabilities">%1$s/%2$d clients connected\nSupported features: %3$s</string>
<string name="tethering_manage_wifi_no_features">None</string>
<string name="connected_state_incomplete">" (connecting)"</string>
<string name="connected_state_valid">" (reachable)"</string>
@@ -104,8 +108,9 @@
<string name="settings_service_repeater_start_on_boot">Start repeater on boot</string>
<string name="settings_service_repeater_safe_mode">Repeater safe mode</string>
<string name="settings_service_repeater_safe_mode_summary">Makes no changes to your system configuration but might
not work with short SSIDs.</string>
<string name="settings_service_repeater_safe_mode_warning">Short SSIDs might require turning off safe mode.</string>
not work with short network names.</string>
<string name="settings_service_repeater_safe_mode_warning">Short network names might require turning off safe
mode.</string>
<string name="settings_service_wifi_lock">Keep Wi\u2011Fi alive</string>
<string name="settings_service_wifi_lock_none">System default</string>
<string name="settings_service_wifi_lock_full">On</string>
@@ -169,11 +174,15 @@
<string name="wifi_security">Security</string>
<string name="wifi_password">Password</string>
<string name="credentials_password_too_short">The password must have at least 8 characters.</string>
<string name="wifi_hotspot_auto_off">Turn off hotspot automatically when no devices are connected</string>
<string name="wifi_hotspot_timeout">Inactive timeout</string>
<string name="wifi_hotspot_timeout_default">Default timeout: %dms</string>
<string name="wifi_hotspot_ap_band_title">AP Band</string>
<string name="wifi_ap_choose_auto">Auto</string>
<string name="wifi_ap_choose_2G">2.4 GHz Band</string>
<string name="wifi_ap_choose_5G">5.0 GHz Band</string>
<string name="wifi_ap_choose_6G">6.0 GHz Band</string>
<string name="wifi_advanced_mac_address_title">MAC address</string>
<string name="wifi_hidden_network">Hidden network</string>
<string name="wifi_save">Save</string>