Skip to content

Commit

Permalink
Add Bakhtiari language support and fix implementation issues (#3952)
Browse files Browse the repository at this point in the history
This commit improves the Bakhtiari language support by addressing issues from PR [#3927](#3927), where the initial implementation had incorrect file placements and lacked necessary changes for functionality.

- Integrated `strings.xml` into the correct `values-bqi-rIR` directory.
- Updated the `Language` enum to include `BAKHTIARI("bqi-rIR")`.
- Modified the `getLocale()` function to handle Bakhtiari with `Locale("bqi", "IR")`.
- Added Bakhtiari to the `language_select` string-array using its native script: `<item>بختیاری</item>`.
- Updated the `language_select_value` string-array to include `<item>bqi-rIR</item>`.

Verified that the language switching works correctly. For grammatical or translation accuracy, a native speaker's review is needed.

@hosseinabaspanah, since I assume Bakhtiari is your native language, could you please review the translations to ensure accuracy?
  • Loading branch information
CodeWithTamim authored Nov 15, 2024
1 parent cee3a0f commit c69a758
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 6 deletions.
3 changes: 2 additions & 1 deletion V2rayNG/app/src/main/java/com/v2ray/ang/dto/Language.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ enum class Language(val code: String) {
VIETNAMESE("vi"),
RUSSIAN("ru"),
PERSIAN("fa"),
BANGLA("bn");
BANGLA("bn"),
BAKHTIARI("bqi-rIR");

companion object {
fun fromCode(code: String): Language {
Expand Down
19 changes: 14 additions & 5 deletions V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ object Utils {
* get remote dns servers from preference
*/
fun getRemoteDnsServers(): List<String> {
val remoteDns = MmkvManager.decodeSettingsString(AppConfig.PREF_REMOTE_DNS) ?: AppConfig.DNS_PROXY
val remoteDns =
MmkvManager.decodeSettingsString(AppConfig.PREF_REMOTE_DNS) ?: AppConfig.DNS_PROXY
val ret = remoteDns.split(",").filter { isPureIpAddress(it) || isCoreDNSAddress(it) }
if (ret.isEmpty()) {
return listOf(AppConfig.DNS_PROXY)
Expand All @@ -149,7 +150,8 @@ object Utils {
* get remote dns servers from preference
*/
fun getDomesticDnsServers(): List<String> {
val domesticDns = MmkvManager.decodeSettingsString(AppConfig.PREF_DOMESTIC_DNS) ?: AppConfig.DNS_DIRECT
val domesticDns =
MmkvManager.decodeSettingsString(AppConfig.PREF_DOMESTIC_DNS) ?: AppConfig.DNS_DIRECT
val ret = domesticDns.split(",").filter { isPureIpAddress(it) || isCoreDNSAddress(it) }
if (ret.isEmpty()) {
return listOf(AppConfig.DNS_DIRECT)
Expand Down Expand Up @@ -357,7 +359,11 @@ object Utils {
}

@Throws(IOException::class)
fun getUrlContentWithCustomUserAgent(urlStr: String?, timeout: Int = 30000, httpPort: Int = 0): String {
fun getUrlContentWithCustomUserAgent(
urlStr: String?,
timeout: Int = 30000,
httpPort: Int = 0
): String {
val url = URL(urlStr)
val conn = if (httpPort == 0) {
url.openConnection()
Expand Down Expand Up @@ -410,7 +416,8 @@ object Utils {
}

fun getLocale(): Locale {
val langCode = MmkvManager.decodeSettingsString(AppConfig.PREF_LANGUAGE) ?: Language.AUTO.code
val langCode =
MmkvManager.decodeSettingsString(AppConfig.PREF_LANGUAGE) ?: Language.AUTO.code
val language = Language.fromCode(langCode)

return when (language) {
Expand All @@ -422,6 +429,7 @@ object Utils {
Language.RUSSIAN -> Locale("ru")
Language.PERSIAN -> Locale("fa")
Language.BANGLA -> Locale("bn")
Language.BAKHTIARI -> Locale("bqi", "IR")
}
}

Expand Down Expand Up @@ -455,7 +463,8 @@ object Utils {
return if (second) {
AppConfig.DelayTestUrl2
} else {
MmkvManager.decodeSettingsString(AppConfig.PREF_DELAY_TEST_URL) ?: AppConfig.DelayTestUrl
MmkvManager.decodeSettingsString(AppConfig.PREF_DELAY_TEST_URL)
?: AppConfig.DelayTestUrl
}
}

Expand Down
Loading

1 comment on commit c69a758

@korekasnadar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename بختیاری to لۊری بختیاری

Please sign in to comment.