From 2d8257d3de90b36531982fb3374291845696d6bb Mon Sep 17 00:00:00 2001 From: Mygod Date: Thu, 29 Dec 2016 00:21:03 +0800 Subject: [PATCH] Localize new strings in drawer --- src/main/res/layout/layout_profiles_item.xml | 4 ++-- src/main/res/values-zh-rCN/strings.xml | 7 +++++++ src/main/res/values-zh-rTW/strings.xml | 7 +++++++ src/main/res/values/strings.xml | 8 ++++++++ .../scala/com/github/shadowsocks/BaseService.scala | 2 +- .../scala/com/github/shadowsocks/MainActivity.scala | 11 +++++------ .../github/shadowsocks/ProfileConfigActivity.scala | 8 ++++---- .../github/shadowsocks/ProfileConfigFragment.scala | 6 +++--- 8 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/main/res/layout/layout_profiles_item.xml b/src/main/res/layout/layout_profiles_item.xml index 8bb44a46..9ddabbb8 100644 --- a/src/main/res/layout/layout_profiles_item.xml +++ b/src/main/res/layout/layout_profiles_item.xml @@ -42,7 +42,7 @@ android:layout_gravity="top" app:srcCompat="@drawable/ic_social_share" android:background="?attr/selectableItemBackgroundBorderless" - android:contentDescription="Share" + android:contentDescription="@string/share" android:focusable="true" android:nextFocusLeft="@+id/container"/> 正在关闭…… 后台服务启动失败:%s VPN 服务启动失败。你可能需要重启设备。 + 是 + 否 关闭 + 请选择配置文件 代理服务器地址及密码不能为空 连接 正在初始化…… @@ -59,6 +62,7 @@ 只需在 NAT 模式下使用,需要 ROOT 权限 在没有 ROOT 权限的情况下无法刷新 DNS 缓存 刷新中…… + 编辑 分享 扫描二维码或使用 Android Beam (NFC) 扫描二维码 @@ -95,6 +99,9 @@ • 点击选择配置文件;\n• 向左/右滑动或按左删除;\n• 长按拖动改变顺序。 好的 + 配置文件设置 + 保存修改吗? + 你是否确定要删除这个配置文件? 复制 URL 为影梭添加此配置文件? 扫描二维码 diff --git a/src/main/res/values-zh-rTW/strings.xml b/src/main/res/values-zh-rTW/strings.xml index 99b76076..8998c6af 100644 --- a/src/main/res/values-zh-rTW/strings.xml +++ b/src/main/res/values-zh-rTW/strings.xml @@ -43,7 +43,10 @@ 關閉中…… %s VPN 服務啟動失敗。您或許需要重新啟動您的裝置。 + 是 + 否 關閉 + 請選擇設定檔 Proxy 或密碼不可以空白 連線 起始中…… @@ -60,6 +63,7 @@ 僅在 NAT 模式可用,需要 ROOT 權限 在無 ROOT 權限時清除 DNS 快取無法進行 清除中…… + 編輯 分享 掃描 QR 碼或者使用 Android Beam (NFC) 掃描 QR 碼 @@ -96,6 +100,9 @@ • 輕觸選擇一個設定檔;\n• 向左/右撥動或按左移除;\n• 按住後上下撥動設定檔重新排序。 我懂了! + 設定檔配置 + 要保存更改嗎? + 您確定要移除這個設定檔嗎? 複製 URL 為 Shadowsocks 新增此設定檔? 掃描 QR 碼 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 2006b67b..0f956cba 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -83,9 +83,13 @@ %s Failed to start VPN service. You might need to reboot your device. Switch + No valid profile data found. + Yes + No Close + Please select a profile Proxy/Password should not be empty Connect Initializing… @@ -100,6 +104,7 @@ Reset all the background services About Shadowsocks %s + Edit Share Scan QR code or use Android Beam (NFC) Scan QR code @@ -123,6 +128,9 @@ • Tap to select a profile;\n• Swipe left/right or press left to remove;\n• Long press to reorder profiles. Gotcha! + Profile config + Changes not saved. Do you want to save? + Are you sure you want to remove this profile? Add this Shadowsocks Profile? Scan QR code Manual Settings diff --git a/src/main/scala/com/github/shadowsocks/BaseService.scala b/src/main/scala/com/github/shadowsocks/BaseService.scala index e51517df..285354f0 100644 --- a/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -113,7 +113,7 @@ trait BaseService extends Service { override def use(profileId: Int): Unit = synchronized(if (profileId < 0) stopRunner(stopService = true) else { val profile = app.profileManager.getProfile(profileId).orNull - if (profile == null) stopRunner(stopService = true, "Please select a profile.") else state match { // TODO: localize + if (profile == null) stopRunner(stopService = true, getString(R.string.profile_empty)) else state match { case State.STOPPED => if (checkProfile(profile)) startRunner(profile) case State.CONNECTED => if (profileId != BaseService.this.profile.id && checkProfile(profile)) { stopRunner(stopService = false) diff --git a/src/main/scala/com/github/shadowsocks/MainActivity.scala b/src/main/scala/com/github/shadowsocks/MainActivity.scala index 4a00ef5f..8e47b8da 100644 --- a/src/main/scala/com/github/shadowsocks/MainActivity.scala +++ b/src/main/scala/com/github/shadowsocks/MainActivity.scala @@ -99,7 +99,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe case _: NullPointerException => } private def changeState(s: Int, profileName: String = null, m: String = null) { - // TODO: localize texts for statusText in this method s match { case State.CONNECTING => fab.setImageResource(R.drawable.ic_start_busy) @@ -314,17 +313,17 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe if (TextUtils.isEmpty(sharedStr)) return val profiles = Parser.findAll(sharedStr).toList if (profiles.isEmpty) { - // TODO: show error msg + Snackbar.make(findViewById(R.id.snackbar), R.string.profile_invalid_input, Snackbar.LENGTH_LONG).show() return } - val dialog = new AlertDialog.Builder(this) + new AlertDialog.Builder(this) .setTitle(R.string.add_profile_dialog) - .setPositiveButton("Yes", ((_, _) => // TODO + .setPositiveButton(R.string.yes, ((_, _) => profiles.foreach(app.profileManager.createProfile)): DialogInterface.OnClickListener) - .setNegativeButton("No", null) + .setNegativeButton(R.string.no, null) .setMessage(profiles.mkString("\n")) .create() - dialog.show() + .show() } def onSharedPreferenceChanged(pref: SharedPreferences, key: String): Unit = key match { diff --git a/src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala b/src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala index 8f64e327..22314ce2 100644 --- a/src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala +++ b/src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala @@ -35,7 +35,7 @@ class ProfileConfigActivity extends Activity { super.onCreate(savedInstanceState) setContentView(R.layout.layout_profile_config) val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar] - toolbar.setTitle("Profile config") // TODO + toolbar.setTitle(R.string.profile_config) toolbar.setNavigationIcon(R.drawable.ic_navigation_close) toolbar.setNavigationOnClickListener(_ => onBackPressed()) toolbar.inflateMenu(R.menu.profile_config_menu) @@ -43,9 +43,9 @@ class ProfileConfigActivity extends Activity { } override def onBackPressed(): Unit = if (app.settings.getBoolean(Key.dirty, false)) new AlertDialog.Builder(this) - .setTitle("Changes not saved. Do you want to save?") // TODO: localizations - .setPositiveButton("Yes", ((_, _) => child.saveAndExit()): DialogInterface.OnClickListener) - .setNegativeButton("No", ((_, _) => finish()): DialogInterface.OnClickListener) + .setTitle(R.string.unsaved_changes_prompt) + .setPositiveButton(R.string.yes, ((_, _) => child.saveAndExit()): DialogInterface.OnClickListener) + .setNegativeButton(R.string.no, ((_, _) => finish()): DialogInterface.OnClickListener) .setNeutralButton(android.R.string.cancel, null) .create() .show() else super.onBackPressed() diff --git a/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala b/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala index d8952daa..4cbdef10 100644 --- a/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala +++ b/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala @@ -83,12 +83,12 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe override def onMenuItemClick(item: MenuItem): Boolean = item.getItemId match { case R.id.action_delete => new AlertDialog.Builder(getActivity) - .setTitle("Confirm?") // TODO - .setPositiveButton("Yes", ((_, _) => { + .setTitle(R.string.delete_confirm_prompt) + .setPositiveButton(R.string.yes, ((_, _) => { app.profileManager.delProfile(profile.id) getActivity.finish() }): DialogInterface.OnClickListener) - .setNegativeButton("No", null) + .setNegativeButton(R.string.no, null) .create() .show() true