Skip to content

Commit

Permalink
Fix translate
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 15, 2024
1 parent fe4aa57 commit 9e6faba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/io/nekohasekai/sfa/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Application : Application() {
super.onCreate()

Seq.setContext(this)
Libbox.setLocale(Locale.getDefault().toLanguageTag())
Libbox.setLocale(Locale.getDefault().toLanguageTag().replace("-", "_"))

@Suppress("OPT_IN_USAGE")
GlobalScope.launch(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.nekohasekai.sfa.ui.profile

import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import io.nekohasekai.libbox.Libbox
Expand All @@ -29,9 +31,13 @@ import java.io.InputStream
import java.util.Date

class NewProfileActivity : AbstractActivity<ActivityAddProfileBinding>() {
enum class FileSource(val formatted: String) {
CreateNew("Create New"),
Import("Import");
enum class FileSource(@StringRes val formattedRes: Int) {
CreateNew(R.string.profile_source_create_new),
Import(R.string.profile_source_import);

fun formatted(context: Context): String {
return context.getString(formattedRes)
}
}

private val importFile =
Expand Down Expand Up @@ -76,12 +82,12 @@ class NewProfileActivity : AbstractActivity<ActivityAddProfileBinding>() {
}
binding.fileSourceMenu.addTextChangedListener {
when (it) {
FileSource.CreateNew.formatted -> {
FileSource.CreateNew.formatted(this) -> {
binding.importFileButton.isVisible = false
binding.sourceURL.isVisible = false
}

FileSource.Import.formatted -> {
FileSource.Import.formatted(this) -> {
binding.importFileButton.isVisible = true
binding.sourceURL.isVisible = true
}
Expand All @@ -101,7 +107,7 @@ class NewProfileActivity : AbstractActivity<ActivityAddProfileBinding>() {
when (binding.type.text) {
TypedProfile.Type.Local.getString(this) -> {
when (binding.fileSourceMenu.text) {
FileSource.Import.formatted -> {
FileSource.Import.formatted(this) -> {
if (binding.sourceURL.showErrorIfEmpty()) {
return
}
Expand Down Expand Up @@ -142,11 +148,11 @@ class NewProfileActivity : AbstractActivity<ActivityAddProfileBinding>() {
typedProfile.type = TypedProfile.Type.Local

when (binding.fileSourceMenu.text) {
FileSource.CreateNew.formatted -> {
FileSource.CreateNew.formatted(this) -> {
configFile.writeText("{}")
}

FileSource.Import.formatted -> {
FileSource.Import.formatted(this) -> {
val sourceURL = binding.sourceURL.text
val content = if (sourceURL.startsWith("content://")) {
val inputStream =
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/io/nekohasekai/sfa/utils/HTTPClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.nekohasekai.libbox.Libbox
import io.nekohasekai.sfa.BuildConfig
import io.nekohasekai.sfa.ktx.unwrap
import java.io.Closeable
import java.util.Locale

class HTTPClient : Closeable {

Expand All @@ -15,6 +16,8 @@ class HTTPClient : Closeable {
userAgent += BuildConfig.VERSION_CODE
userAgent += "; sing-box "
userAgent += Libbox.version()
userAgent += "; language "
userAgent += Locale.getDefault().toLanguageTag().replace("-", "_")
userAgent += ")"
userAgent
}
Expand Down

0 comments on commit 9e6faba

Please sign in to comment.