diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 83d55ca7a..63d2300ec 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -273,6 +273,8 @@ 62E2BF4B2B4082BA00E42D38 /* AliResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF482B4082BA00E42D38 /* AliResponse.swift */; }; 62E2BF4C2B4082BA00E42D38 /* AliTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF492B4082BA00E42D38 /* AliTranslateType.swift */; }; 62ED29A22B15F1F500901F51 /* EZWrapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62ED29A12B15F1F500901F51 /* EZWrapView.m */; }; + 6A47D40C2B9576050077B2F3 /* EZI18nHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */; }; + 6A6352282B94603A00AD9FCF /* LanguageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A6352272B94603A00AD9FCF /* LanguageState.swift */; }; 960835502B6791F200C6A931 /* Shortcut+Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */; }; 96099AE22B5D40330055C4DD /* ShortcutTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96099AE12B5D40330055C4DD /* ShortcutTab.swift */; }; 9627F9382B59956800B1E999 /* GlobalShortcutSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9627F9352B59956800B1E999 /* GlobalShortcutSetting.swift */; }; @@ -800,6 +802,8 @@ 62ED29A02B15F1F500901F51 /* EZWrapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZWrapView.h; sourceTree = ""; }; 62ED29A12B15F1F500901F51 /* EZWrapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZWrapView.m; sourceTree = ""; }; 6372B33DFF803C7096A82250 /* Pods_Easydict.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Easydict.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EZI18nHelper.swift; sourceTree = ""; }; + 6A6352272B94603A00AD9FCF /* LanguageState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageState.swift; sourceTree = ""; }; 91E3E579C6DB88658B4BB102 /* Pods-Easydict.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Easydict.release.xcconfig"; path = "Target Support Files/Pods-Easydict/Pods-Easydict.release.xcconfig"; sourceTree = ""; }; 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Validator.swift"; sourceTree = ""; }; 96099AE12B5D40330055C4DD /* ShortcutTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutTab.swift; sourceTree = ""; }; @@ -2240,6 +2244,15 @@ path = EZWrapView; sourceTree = ""; }; + 6A47D40A2B9575C00077B2F3 /* LanguagePreference */ = { + isa = PBXGroup; + children = ( + 6A6352272B94603A00AD9FCF /* LanguageState.swift */, + 6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */, + ); + path = LanguagePreference; + sourceTree = ""; + }; 713A345D86B5BC86D158B68F /* Frameworks */ = { isa = PBXGroup; children = ( @@ -2283,6 +2296,7 @@ 967712EB2B5B93E200105E0F /* Feature */ = { isa = PBXGroup; children = ( + 6A47D40A2B9575C00077B2F3 /* LanguagePreference */, 967712EC2B5B941600105E0F /* Shortcut */, ); path = Feature; @@ -2842,6 +2856,7 @@ 03991158292927E000E1B06D /* EZTitlebar.m in Sources */, 03D8A65C2A433B4100D9A968 /* EZConfiguration+EZUserData.m in Sources */, 03BD282229486CF200F5891A /* EZBlueTextButton.m in Sources */, + 6A47D40C2B9576050077B2F3 /* EZI18nHelper.swift in Sources */, 0AC8A8472B6A4E3F006DA5CC /* ServiceConfigurationSecretSectionView.swift in Sources */, 03BDA7C22A26DA280079D04F /* NSString+Indenter.m in Sources */, 03542A462937B4C300C34C33 /* EZBaiduTranslateResponse.m in Sources */, @@ -3041,6 +3056,7 @@ 03B0232A29231FA6001C7E63 /* NSColor+MyColors.m in Sources */, C4DD01ED2B12BE9B0025EE8E /* TencentTranslateType.swift in Sources */, 0AC8A83D2B6685EE006DA5CC /* SecureTextField.swift in Sources */, + 6A6352282B94603A00AD9FCF /* LanguageState.swift in Sources */, 0AC8A8372B6659A8006DA5CC /* NiuTransTranslate+ConfigurableService.swift in Sources */, 03D043562928940500E7559E /* EZBaseQueryWindow.m in Sources */, 03BDA7B92A26DA280079D04F /* NSProcessInfo+XPMArgumentParser.m in Sources */, diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index e49d75387..4b58f308a 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -13,6 +13,7 @@ }, "about" : { "comment" : "about", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -29,6 +30,7 @@ } }, "adjust_pop_button_origin" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -45,6 +47,7 @@ } }, "advanced" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -89,6 +92,7 @@ } }, "allow_collect_analytics" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -105,6 +109,7 @@ } }, "allow_collect_crash_log" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -121,6 +126,7 @@ } }, "analytics" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -154,6 +160,7 @@ } }, "app_appearance" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -187,6 +194,7 @@ } }, "appearenceType_dark" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -203,6 +211,7 @@ } }, "appearenceType_followSystem" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -219,6 +228,7 @@ } }, "appearenceType_light" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -246,6 +256,7 @@ } }, "apple_dictionary" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -262,6 +273,7 @@ } }, "apple_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -278,6 +290,7 @@ } }, "author" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -294,6 +307,7 @@ } }, "auto_check_update" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -310,6 +324,7 @@ } }, "auto_check_update " : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -326,6 +341,7 @@ } }, "auto_copy_first_translated_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -342,6 +358,7 @@ } }, "auto_copy_ocr_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -358,6 +375,7 @@ } }, "auto_copy_selected_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -374,6 +392,7 @@ } }, "auto_copy_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -390,6 +409,7 @@ } }, "auto_get_selected_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -406,6 +426,7 @@ } }, "auto_play_word_audio" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -422,6 +443,7 @@ } }, "auto_query" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -438,6 +460,7 @@ } }, "auto_query_ocr_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -454,6 +477,7 @@ } }, "auto_query_pasted_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -470,6 +494,7 @@ } }, "auto_query_selected_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -486,6 +511,7 @@ } }, "auto_show_query_icon" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -502,6 +528,7 @@ } }, "automatic_word_segmentation" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -518,6 +545,7 @@ } }, "automatically_remove_code_comment_symbols" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -534,6 +562,7 @@ } }, "avoid_conflict_with_PopClip_display" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -561,6 +590,7 @@ } }, "baidu_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -577,6 +607,7 @@ } }, "beta_new_app" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -593,6 +624,7 @@ } }, "bing_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -637,6 +669,7 @@ } }, "cancel" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -653,6 +686,7 @@ } }, "check_for_updates" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -669,6 +703,7 @@ } }, "check_now" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -685,6 +720,7 @@ } }, "check_updates" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -701,6 +737,7 @@ } }, "chinese_phonetic" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -717,6 +754,7 @@ } }, "clear_all" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -733,6 +771,7 @@ } }, "clear_input_when_translating" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -749,6 +788,7 @@ } }, "click_icon_query" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -765,6 +805,7 @@ } }, "click_icon_query_info" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -798,6 +839,7 @@ } }, "comparative" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -814,6 +856,7 @@ } }, "copy_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -830,6 +873,7 @@ } }, "crash_log" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -846,6 +890,7 @@ } }, "current_version" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -890,6 +935,7 @@ } }, "deepL_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -906,6 +952,7 @@ } }, "default_tts_service" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -923,6 +970,7 @@ }, "detected" : { "comment" : "query window", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -939,6 +987,7 @@ } }, "disable_crash_log_warning" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -955,6 +1004,7 @@ } }, "disable_empty_copy_beep" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -971,6 +1021,7 @@ } }, "disable_empty_copy_beep_msg" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1005,6 +1056,7 @@ }, "disabled_app_list" : { "comment" : "disabled app list", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1021,6 +1073,7 @@ } }, "disabled_title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1057,6 +1110,7 @@ } }, "enable_beta_new_app" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1073,6 +1127,7 @@ } }, "equal_first_and_second_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1089,6 +1144,7 @@ } }, "error_api" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1105,6 +1161,7 @@ } }, "error_insufficient_quota" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1121,6 +1178,7 @@ } }, "error_network" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1138,6 +1196,7 @@ }, "error_parameter" : { "comment" : "error msg", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1154,6 +1213,7 @@ } }, "error_unknown" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1170,6 +1230,7 @@ } }, "error_unsupport_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1186,6 +1247,7 @@ } }, "etymology" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1202,6 +1264,7 @@ } }, "Export Log" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -1223,6 +1286,7 @@ } }, "Feedback" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -1233,6 +1297,7 @@ } }, "first_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1249,6 +1314,7 @@ } }, "fixed_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1265,6 +1331,7 @@ } }, "fixed_window_position" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1281,6 +1348,7 @@ } }, "fixed_window_position_center" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1297,6 +1365,7 @@ } }, "fixed_window_position_former" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1313,6 +1382,7 @@ } }, "fixed_window_position_mouse" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1329,6 +1399,7 @@ } }, "fixed_window_position_right" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1362,6 +1433,7 @@ } }, "force_auto_get_selected_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1378,6 +1450,7 @@ } }, "force_auto_get_selected_text_msg" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1394,6 +1467,7 @@ } }, "force_auto_get_selected_text_title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1481,6 +1555,7 @@ } }, "google_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1497,6 +1572,7 @@ } }, "Help" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -1507,6 +1583,7 @@ } }, "hide" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1523,6 +1600,7 @@ } }, "hide_main_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1539,6 +1617,7 @@ } }, "hide_menu_bar_icon" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1555,6 +1634,7 @@ } }, "hide_menu_bar_icon_msg" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1621,6 +1701,7 @@ } }, "input_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1648,6 +1729,7 @@ } }, "insufficient_quota_prompt" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1698,6 +1780,7 @@ } }, "language_detect_optimize" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1714,6 +1797,7 @@ } }, "language_detect_optimize_baidu" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1730,6 +1814,7 @@ } }, "language_detect_optimize_google" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1746,6 +1831,7 @@ } }, "language_detect_optimize_none" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1761,6 +1847,23 @@ } } }, + "language_preference" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Display Language" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "显示语言" + } + } + } + }, "large" : { "extractionState" : "manual", "localizations" : { @@ -1779,6 +1882,7 @@ } }, "lastest_version" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1811,6 +1915,7 @@ } }, "launch" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1827,6 +1932,7 @@ } }, "launch_at_startup" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1843,6 +1949,7 @@ } }, "Log Directory" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -1853,6 +1960,7 @@ } }, "main_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1880,6 +1988,7 @@ } }, "menu_bar_icon" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1946,6 +2055,7 @@ } }, "menu_selectWord_Translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1962,6 +2072,7 @@ } }, "menu_show_mini_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1978,6 +2089,7 @@ } }, "menu_silent_screenshot_OCR" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -1994,6 +2106,7 @@ } }, "mini_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2027,6 +2140,7 @@ } }, "mouse_select_translate_window_type" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2043,6 +2157,7 @@ } }, "niuTrans_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2059,6 +2174,7 @@ } }, "no_results_found" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2075,6 +2191,7 @@ } }, "none_window" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -2085,6 +2202,7 @@ } }, "ocr_result_is_empty" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2117,6 +2235,7 @@ } }, "open_in_apple_dictionary" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2133,6 +2252,7 @@ } }, "open_in_eudic" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2149,6 +2269,7 @@ } }, "open_in_google" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2165,6 +2286,7 @@ } }, "open_web_link" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2181,6 +2303,7 @@ } }, "openai_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2208,6 +2331,7 @@ } }, "past" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2224,6 +2348,7 @@ } }, "past_participle" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2240,6 +2365,7 @@ } }, "pin" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2256,6 +2382,7 @@ } }, "placeholder" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2272,6 +2399,7 @@ } }, "play_audio" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2288,6 +2416,7 @@ } }, "play_word_audio" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2304,6 +2433,7 @@ } }, "please_look" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2320,6 +2450,7 @@ } }, "plural" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2336,6 +2467,7 @@ } }, "present_participle" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2353,6 +2485,7 @@ }, "privacy" : { "comment" : "privacy", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2369,6 +2502,7 @@ } }, "privacy_statement" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2385,6 +2519,7 @@ } }, "privacy_statement_content" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2401,6 +2536,7 @@ } }, "query_failed" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2417,6 +2553,7 @@ } }, "query_in_app" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2433,6 +2570,7 @@ } }, "quick_link" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2449,6 +2587,7 @@ } }, "quit" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2498,6 +2637,7 @@ } }, "replace_text" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2514,6 +2654,7 @@ } }, "retry" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2530,6 +2671,7 @@ } }, "root" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2546,6 +2688,7 @@ } }, "second_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2579,6 +2722,7 @@ } }, "select_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2596,6 +2740,7 @@ }, "service" : { "comment" : "service", + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2675,23 +2820,8 @@ } } }, - "service.configuration.custom_openai.name.title" : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Custom Service Name" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "自定义服务名称" - } - } - } - }, "service.configuration.custom_openai.model.placeholder" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2707,7 +2837,24 @@ } } }, + "service.configuration.custom_openai.name.title" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Custom Service Name" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "自定义服务名称" + } + } + } + }, "service.configuration.custom_openai.supported_models.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2740,6 +2887,7 @@ } }, "service.configuration.deepl.authkey_first.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2756,6 +2904,7 @@ } }, "service.configuration.deepl.authkey_only.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -2820,6 +2969,7 @@ } }, "service.configuration.deepl.web_first.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3012,6 +3162,7 @@ } }, "service.configuration.openai.usage_status_always_off.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3028,6 +3179,7 @@ } }, "service.configuration.openai.usage_status_always_on.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3044,6 +3196,7 @@ } }, "service.configuration.openai.usage_status_default.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3172,6 +3325,7 @@ } }, "setting_general" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3205,6 +3359,7 @@ } }, "setting.general.advance.default_tts_service" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3221,6 +3376,7 @@ } }, "setting.general.advance.enable_beta_feature" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3237,6 +3393,7 @@ } }, "setting.general.advance.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3252,7 +3409,25 @@ } } }, + "setting.general.app_setting.header" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "App Settings" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "应用设置" + } + } + } + }, "setting.general.appearance.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3269,6 +3444,7 @@ } }, "setting.general.appearance.light_dark_appearance" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3285,6 +3461,7 @@ } }, "setting.general.auto_copy.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3301,6 +3478,7 @@ } }, "setting.general.auto_query.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3317,6 +3495,7 @@ } }, "setting.general.font.font_size.label" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3333,6 +3512,7 @@ } }, "setting.general.font.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3349,6 +3529,7 @@ } }, "setting.general.input.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3381,6 +3562,7 @@ } }, "setting.general.language.duplicated_alert.field.first" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3397,6 +3579,7 @@ } }, "setting.general.language.duplicated_alert.field.second" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3413,6 +3596,7 @@ } }, "setting.general.language.duplicated_alert.title" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3429,6 +3613,7 @@ } }, "setting.general.language.first_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3445,6 +3630,7 @@ } }, "setting.general.language.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3461,6 +3647,7 @@ } }, "setting.general.language.language_detect_optimize" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3477,6 +3664,7 @@ } }, "setting.general.language.second_language" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3493,6 +3681,7 @@ } }, "setting.general.mouse_query.adjust_pop_button_origin" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3509,6 +3698,7 @@ } }, "setting.general.mouse_query.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3542,6 +3732,7 @@ } }, "setting.general.quick_link.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3558,6 +3749,7 @@ } }, "setting.general.voice.auto_play_word_audio" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3574,6 +3766,7 @@ } }, "setting.general.voice.disable_empty_copy_beep_msg" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3590,6 +3783,7 @@ } }, "setting.general.voice.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3606,6 +3800,7 @@ } }, "setting.general.window.fixed_window_position" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3622,6 +3817,7 @@ } }, "setting.general.window.mouse_select_translate_window_type" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3638,6 +3834,7 @@ } }, "setting.general.window.shortcut_select_translate_window_type" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3654,6 +3851,7 @@ } }, "setting.general.windows.header" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3686,6 +3884,7 @@ } }, "setting.service.detail.no_selection" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3702,6 +3901,7 @@ } }, "setting.tts_service.options.apple" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3718,6 +3918,7 @@ } }, "setting.tts_service.options.baidu" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3734,6 +3935,7 @@ } }, "setting.tts_service.options.bing" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3750,6 +3952,7 @@ } }, "setting.tts_service.options.google" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3766,6 +3969,7 @@ } }, "setting.tts_service.options.youdao" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -3782,6 +3986,7 @@ } }, "Settings..." : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -4012,6 +4217,7 @@ } }, "shortcut_select_translate_window_type" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4028,6 +4234,7 @@ } }, "show" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4044,6 +4251,7 @@ } }, "show_apple_dictionary_quick_link" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4060,6 +4268,7 @@ } }, "show_eudic_quick_link" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4076,6 +4285,7 @@ } }, "show_google_quick_link" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4092,6 +4302,7 @@ } }, "show_main_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4108,6 +4319,7 @@ } }, "show_mini_window" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4140,6 +4352,7 @@ } }, "silent_screenshot_ocr" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4156,6 +4369,7 @@ } }, "singular" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4189,6 +4403,7 @@ } }, "snip_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4205,6 +4420,7 @@ } }, "stop_play_audio" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4232,6 +4448,7 @@ } }, "superlative" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4478,6 +4695,7 @@ } }, "toggle_languages" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4494,6 +4712,7 @@ } }, "uk_phonetic" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4532,6 +4751,7 @@ } }, "unknown_option" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -4542,6 +4762,7 @@ } }, "unpin" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4558,6 +4779,7 @@ } }, "us_phonetic" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4574,6 +4796,7 @@ } }, "volcano_translate" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4617,6 +4840,7 @@ } }, "youdao_dict" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4634,4 +4858,4 @@ } }, "version" : "1.0" -} +} \ No newline at end of file diff --git a/Easydict/App/PrefixHeader.pch b/Easydict/App/PrefixHeader.pch index 9f259206c..875886b8a 100644 --- a/Easydict/App/PrefixHeader.pch +++ b/Easydict/App/PrefixHeader.pch @@ -40,3 +40,7 @@ #import "EZConst.h" #import "EZConstKey.h" #import "NSString+EZConvenience.h" + +#import "Easydict-Swift.h" + +#define EZLocalizedString(key) ([EZI18nHelper localizedWithKey:key]) diff --git a/Easydict/Feature/Configuration/Appearance.swift b/Easydict/Feature/Configuration/Appearance.swift index dcc94aa02..c86b4af18 100644 --- a/Easydict/Feature/Configuration/Appearance.swift +++ b/Easydict/Feature/Configuration/Appearance.swift @@ -22,11 +22,11 @@ enum AppearenceType: Int, CaseIterable, Defaults.Serializable { var title: String { switch self { case .followSystem: - NSLocalizedString("appearenceType_followSystem", comment: "") + "appearenceType_followSystem".localized case .light: - NSLocalizedString("appearenceType_light", comment: "") + "appearenceType_light".localized case .dark: - NSLocalizedString("appearenceType_dark", comment: "") + "appearenceType_dark".localized } } diff --git a/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m b/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m index 8df326346..2390ce4db 100644 --- a/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m +++ b/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m @@ -95,7 +95,7 @@ - (void)setupAppModelList { - (NSTextField *)titleTextField { if (!_titleTextField) { - NSTextField *titleTextField = [NSTextField wrappingLabelWithString:NSLocalizedString(@"disabled_title", nil)]; + NSTextField *titleTextField = [NSTextField wrappingLabelWithString:EZLocalizedString(@"disabled_title")]; [self.view addSubview:titleTextField]; titleTextField.font = [NSFont systemFontOfSize:14]; _titleTextField = titleTextField; @@ -327,7 +327,7 @@ - (NSString *)viewIdentifier { } - (NSString *)toolbarItemLabel { - return NSLocalizedString(@"disabled_app_list", nil); + return EZLocalizedString(@"disabled_app_list"); } - (NSImage *)toolbarItemImage { diff --git a/Easydict/Feature/PerferenceWindow/EZAboutViewController.m b/Easydict/Feature/PerferenceWindow/EZAboutViewController.m index 9196c696a..792de4733 100644 --- a/Easydict/Feature/PerferenceWindow/EZAboutViewController.m +++ b/Easydict/Feature/PerferenceWindow/EZAboutViewController.m @@ -59,17 +59,17 @@ - (void)setupUI { NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; - NSString *versionString = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"current_version", nil), version]; + NSString *versionString = [NSString stringWithFormat:@"%@ %@", EZLocalizedString(@"current_version"), version]; NSTextField *versionValueTextField = [NSTextField labelWithString:versionString]; versionValueTextField.font = [NSFont systemFontOfSize:14]; [self.contentView addSubview:versionValueTextField]; self.currentVersionTextField = versionValueTextField; - NSString *autoCheckUpdateTitle = NSLocalizedString(@"auto_check_update", nil); + NSString *autoCheckUpdateTitle = EZLocalizedString(@"auto_check_update"); self.autoCheckUpdateButton = [NSButton checkboxWithTitle:autoCheckUpdateTitle target:self action:@selector(autoCheckUpdateButtonClicked:)]; [self.contentView addSubview:self.autoCheckUpdateButton]; - NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", NSLocalizedString(@"lastest_version", nil), version]; + NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", EZLocalizedString(@"lastest_version"), version]; NSTextField *latestVersionTextField = [NSTextField labelWithString:latestVersionString]; [self.contentView addSubview:latestVersionTextField]; self.latestVersionTextField = latestVersionTextField; @@ -77,7 +77,7 @@ - (void)setupUI { self.authorView = [[NSView alloc] init]; [self.contentView addSubview:self.authorView]; - NSTextField *authorTextField = [NSTextField labelWithString:NSLocalizedString(@"author", nil)]; + NSTextField *authorTextField = [NSTextField labelWithString:EZLocalizedString(@"author")]; [self.authorView addSubview:authorTextField]; self.authorTextField = authorTextField; @@ -103,7 +103,7 @@ - (void)setupUI { authorLinkButton.openURL = authorURL; // https://github.com/tisfeng authorLinkButton.closeWindowAfterOpeningURL = YES; - NSTextField *githubTextField = [NSTextField labelWithString:NSLocalizedString(@"GitHub:", nil)]; + NSTextField *githubTextField = [NSTextField labelWithString:EZLocalizedString(@"GitHub:")]; [self.contentView addSubview:githubTextField]; self.githubTextField = githubTextField; @@ -183,7 +183,7 @@ - (void)autoCheckUpdateButtonClicked:(NSButton *)sender { - (void)updateLatestVersion { [EZMenuItemManager.shared fetchRepoLatestVersion:EZGithubRepoEasydict completion:^(NSString *latestVersion) { - NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", NSLocalizedString(@"lastest_version", nil), latestVersion]; + NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", EZLocalizedString(@"lastest_version"), latestVersion]; self.latestVersionTextField.stringValue = latestVersionString; }]; } @@ -207,7 +207,7 @@ - (NSString *)viewIdentifier { } - (NSString *)toolbarItemLabel { - return NSLocalizedString(@"about", nil); + return EZLocalizedString(@"about"); } - (NSImage *)toolbarItemImage { diff --git a/Easydict/Feature/PerferenceWindow/EZPrivacyViewController.m b/Easydict/Feature/PerferenceWindow/EZPrivacyViewController.m index fb00a64e3..1b8303191 100644 --- a/Easydict/Feature/PerferenceWindow/EZPrivacyViewController.m +++ b/Easydict/Feature/PerferenceWindow/EZPrivacyViewController.m @@ -37,27 +37,27 @@ - (void)viewDidLoad { } - (void)setupUI { - self.privacyStatementTextField = [NSTextField labelWithString:NSLocalizedString(@"privacy_statement", nil)]; + self.privacyStatementTextField = [NSTextField labelWithString:EZLocalizedString(@"privacy_statement")]; [self.contentView addSubview:self.privacyStatementTextField]; self.privacyStatementTextField.font = [NSFont systemFontOfSize:14]; - self.privacyStatementContentTextField = [NSTextField wrappingLabelWithString:NSLocalizedString(@"privacy_statement_content", nil)]; + self.privacyStatementContentTextField = [NSTextField wrappingLabelWithString:EZLocalizedString(@"privacy_statement_content")]; [self.contentView addSubview:self.privacyStatementContentTextField]; self.privacyStatementContentTextField.preferredMaxLayoutWidth = 380; - self.crashLogTextField = [NSTextField labelWithString:NSLocalizedString(@"crash_log", nil)]; + self.crashLogTextField = [NSTextField labelWithString:EZLocalizedString(@"crash_log")]; [self.contentView addSubview:self.crashLogTextField]; - self.crashLogButton = [NSButton checkboxWithTitle:NSLocalizedString(@"allow_collect_crash_log", nil) + self.crashLogButton = [NSButton checkboxWithTitle:EZLocalizedString(@"allow_collect_crash_log") target:self action:@selector(crashLogButtonClicked:)]; [self.contentView addSubview:self.crashLogButton]; - self.analyticsTextField = [NSTextField labelWithString:NSLocalizedString(@"analytics", nil)]; + self.analyticsTextField = [NSTextField labelWithString:EZLocalizedString(@"analytics")]; [self.contentView addSubview:self.analyticsTextField]; - self.analyticsButton = [NSButton checkboxWithTitle:NSLocalizedString(@"allow_collect_analytics", nil) + self.analyticsButton = [NSButton checkboxWithTitle:EZLocalizedString(@"allow_collect_analytics") target:self action:@selector(analyticsButtonClicked:)]; [self.contentView addSubview:self.analyticsButton]; @@ -111,9 +111,9 @@ - (void)updateViewConstraints { - (void)crashLogButtonClicked:(NSButton *)sender { if (!sender.mm_isOn) { NSAlert *alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle:NSLocalizedString(@"ok", nil)]; - [alert addButtonWithTitle:NSLocalizedString(@"cancel", nil)]; - alert.messageText = NSLocalizedString(@"disable_crash_log_warning", nil); + [alert addButtonWithTitle:EZLocalizedString(@"ok")]; + [alert addButtonWithTitle:EZLocalizedString(@"cancel")]; + alert.messageText = EZLocalizedString(@"disable_crash_log_warning"); [alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) { // ok, disable crash log if (returnCode == NSAlertFirstButtonReturn) { @@ -140,7 +140,7 @@ - (NSString *)viewIdentifier { } - (NSString *)toolbarItemLabel { - return NSLocalizedString(@"privacy", nil); + return EZLocalizedString(@"privacy"); } - (NSImage *)toolbarItemImage { diff --git a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m index 2a9b06e06..cc288034b 100644 --- a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m +++ b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m @@ -177,28 +177,28 @@ - (void)viewDidLoad { - (void)setupUI { NSFont *font = [NSFont systemFontOfSize:13]; - NSTextField *inputLabel = [NSTextField labelWithString:NSLocalizedString(@"input_translate", nil)]; + NSTextField *inputLabel = [NSTextField labelWithString:EZLocalizedString(@"input_translate")]; inputLabel.font = font; [self.contentView addSubview:inputLabel]; self.inputLabel = inputLabel; self.inputShortcutView = [[MASShortcutView alloc] init]; [self.contentView addSubview:self.inputShortcutView]; - NSTextField *snipLabel = [NSTextField labelWithString:NSLocalizedString(@"snip_translate", nil)]; + NSTextField *snipLabel = [NSTextField labelWithString:EZLocalizedString(@"snip_translate")]; snipLabel.font = font; [self.contentView addSubview:snipLabel]; self.snipLabel = snipLabel; self.snipShortcutView = [[MASShortcutView alloc] init]; [self.contentView addSubview:self.snipShortcutView]; - NSTextField *selectLabel = [NSTextField labelWithString:NSLocalizedString(@"select_translate", nil)]; + NSTextField *selectLabel = [NSTextField labelWithString:EZLocalizedString(@"select_translate")]; selectLabel.font = font; [self.contentView addSubview:selectLabel]; self.selectLabel = selectLabel; self.selectionShortcutView = [[MASShortcutView alloc] init]; [self.contentView addSubview:self.selectionShortcutView]; - NSTextField *showMiniLabel = [NSTextField labelWithString:NSLocalizedString(@"show_mini_window", nil)]; + NSTextField *showMiniLabel = [NSTextField labelWithString:EZLocalizedString(@"show_mini_window")]; showMiniLabel.font = font; [self.contentView addSubview:showMiniLabel]; self.showMiniLabel = showMiniLabel; @@ -209,7 +209,7 @@ - (void)setupUI { self.leftmostView = self.showMiniLabel; } - NSTextField *screenshotOCRLabel = [NSTextField labelWithString:NSLocalizedString(@"silent_screenshot_ocr", nil)]; + NSTextField *screenshotOCRLabel = [NSTextField labelWithString:EZLocalizedString(@"silent_screenshot_ocr")]; screenshotOCRLabel.font = font; [self.contentView addSubview:screenshotOCRLabel]; self.screenshotOCRLabel = screenshotOCRLabel; @@ -237,7 +237,7 @@ - (void)setupUI { view.layer.backgroundColor = separatorDarkColor.CGColor; }]; - NSTextField *firstLanguageLabel = [NSTextField labelWithString:NSLocalizedString(@"first_language", nil)]; + NSTextField *firstLanguageLabel = [NSTextField labelWithString:EZLocalizedString(@"first_language")]; firstLanguageLabel.font = font; [self.contentView addSubview:firstLanguageLabel]; self.firstLanguageLabel = firstLanguageLabel; @@ -248,7 +248,7 @@ - (void)setupUI { self.firstLanguagePopUpButton.target = self; self.firstLanguagePopUpButton.action = @selector(firstLangaugePopUpButtonClicked:); - NSTextField *apperanceLabel = [NSTextField labelWithString:NSLocalizedString(@"app_appearance", nil)]; + NSTextField *apperanceLabel = [NSTextField labelWithString:EZLocalizedString(@"app_appearance")]; apperanceLabel.font = font; [self.contentView addSubview:apperanceLabel]; self.apperanceLabel = apperanceLabel; @@ -260,7 +260,7 @@ - (void)setupUI { self.apperancePopUpButton.target = self; self.apperancePopUpButton.action = @selector(appearancePopUpButtonClicked:); - NSTextField *secondLanguageLabel = [NSTextField labelWithString:NSLocalizedString(@"second_language", nil)]; + NSTextField *secondLanguageLabel = [NSTextField labelWithString:EZLocalizedString(@"second_language")]; secondLanguageLabel.font = font; [self.contentView addSubview:secondLanguageLabel]; self.secondLanguageLabel = secondLanguageLabel; @@ -272,50 +272,50 @@ - (void)setupUI { self.secondLanguagePopUpButton.action = @selector(secondLangaugePopUpButtonClicked:); - NSTextField *showQueryIconLabel = [NSTextField labelWithString:NSLocalizedString(@"auto_get_selected_text", nil)]; + NSTextField *showQueryIconLabel = [NSTextField labelWithString:EZLocalizedString(@"auto_get_selected_text")]; showQueryIconLabel.font = font; [self.contentView addSubview:showQueryIconLabel]; self.autoGetSelectedTextLabel = showQueryIconLabel; - NSString *showQueryIconTitle = NSLocalizedString(@"auto_show_query_icon", nil); + NSString *showQueryIconTitle = EZLocalizedString(@"auto_show_query_icon"); self.showQueryIconButton = [NSButton checkboxWithTitle:showQueryIconTitle target:self action:@selector(autoSelectTextButtonClicked:)]; [self.contentView addSubview:self.showQueryIconButton]; - NSString *forceGetSelectedText = NSLocalizedString(@"force_auto_get_selected_text", nil); + NSString *forceGetSelectedText = EZLocalizedString(@"force_auto_get_selected_text"); self.forceGetSelectedTextButton = [NSButton checkboxWithTitle:forceGetSelectedText target:self action:@selector(forceGetSelectedTextButtonClicked:)]; [self.contentView addSubview:self.forceGetSelectedTextButton]; - NSTextField *disableEmptyCopyBeepLabel = [NSTextField labelWithString:NSLocalizedString(@"disable_empty_copy_beep", nil)]; + NSTextField *disableEmptyCopyBeepLabel = [NSTextField labelWithString:EZLocalizedString(@"disable_empty_copy_beep")]; disableEmptyCopyBeepLabel.font = font; [self.contentView addSubview:disableEmptyCopyBeepLabel]; self.disableEmptyCopyBeepLabel = disableEmptyCopyBeepLabel; - NSString *disableEmptyCopyBeepTitle = NSLocalizedString(@"disable_empty_copy_beep_msg", nil); + NSString *disableEmptyCopyBeepTitle = EZLocalizedString(@"disable_empty_copy_beep_msg"); self.disableEmptyCopyBeepButton = [NSButton checkboxWithTitle:disableEmptyCopyBeepTitle target:self action:@selector(disableEmptyCopyBeepButtonClicked:)]; [self.contentView addSubview:self.disableEmptyCopyBeepButton]; - NSTextField *clickQueryLabel = [NSTextField labelWithString:NSLocalizedString(@"click_icon_query", nil)]; + NSTextField *clickQueryLabel = [NSTextField labelWithString:EZLocalizedString(@"click_icon_query")]; clickQueryLabel.font = font; [self.contentView addSubview:clickQueryLabel]; self.clickQueryLabel = clickQueryLabel; - NSString *clickQueryTitle = NSLocalizedString(@"click_icon_query_info", nil); + NSString *clickQueryTitle = EZLocalizedString(@"click_icon_query_info"); self.clickQueryButton = [NSButton checkboxWithTitle:clickQueryTitle target:self action:@selector(clickQueryButtonClicked:)]; [self.contentView addSubview:self.clickQueryButton]; - NSTextField *adjustQueryIconPostionLabel = [NSTextField labelWithString:NSLocalizedString(@"adjust_pop_button_origin", nil)]; + NSTextField *adjustQueryIconPostionLabel = [NSTextField labelWithString:EZLocalizedString(@"adjust_pop_button_origin")]; adjustQueryIconPostionLabel.font = font; [self.contentView addSubview:adjustQueryIconPostionLabel]; self.adjustQueryIconPostionLabel = adjustQueryIconPostionLabel; - NSString *adjustQueryIconPostionTitle = NSLocalizedString(@"avoid_conflict_with_PopClip_display", nil); + NSString *adjustQueryIconPostionTitle = EZLocalizedString(@"avoid_conflict_with_PopClip_display"); self.adjustQueryIconPostionButton = [NSButton checkboxWithTitle:adjustQueryIconPostionTitle target:self action:@selector(adjustQueryIconPostionButtonClicked:)]; [self.contentView addSubview:self.adjustQueryIconPostionButton]; // language detect - NSTextField *usesLanguageCorrectionLabel = [NSTextField labelWithString:NSLocalizedString(@"language_detect_optimize", nil)]; + NSTextField *usesLanguageCorrectionLabel = [NSTextField labelWithString:EZLocalizedString(@"language_detect_optimize")]; usesLanguageCorrectionLabel.font = font; [self.contentView addSubview:usesLanguageCorrectionLabel]; self.languageDetectLabel = usesLanguageCorrectionLabel; @@ -323,16 +323,16 @@ - (void)setupUI { [self.contentView addSubview:self.languageDetectOptimizePopUpButton]; NSArray *languageDetectOptimizeItems = @[ - NSLocalizedString(@"language_detect_optimize_none", nil), - NSLocalizedString(@"language_detect_optimize_baidu", nil), - NSLocalizedString(@"language_detect_optimize_google", nil), + EZLocalizedString(@"language_detect_optimize_none"), + EZLocalizedString(@"language_detect_optimize_baidu"), + EZLocalizedString(@"language_detect_optimize_google"), ]; [self.languageDetectOptimizePopUpButton addItemsWithTitles:languageDetectOptimizeItems]; self.languageDetectOptimizePopUpButton.target = self; self.languageDetectOptimizePopUpButton.action = @selector(languageDetectOptimizePopUpButtonClicked:); // default tts service - NSTextField *defaultTTSServiceLabel = [NSTextField labelWithString:NSLocalizedString(@"default_tts_service", nil)]; + NSTextField *defaultTTSServiceLabel = [NSTextField labelWithString:EZLocalizedString(@"default_tts_service")]; defaultTTSServiceLabel.font = font; [self.contentView addSubview:defaultTTSServiceLabel]; self.defaultTTSServiceLabel = defaultTTSServiceLabel; @@ -342,7 +342,7 @@ - (void)setupUI { NSMutableArray *localizedTTSTitles = [NSMutableArray array]; for (NSString *ttsType in self.enabledTTSServiceTypes) { - NSString *localizedTitle = NSLocalizedString(ttsType, nil); + NSString *localizedTitle = EZLocalizedString(ttsType); [localizedTTSTitles addObject:localizedTitle]; } @@ -350,7 +350,7 @@ - (void)setupUI { self.defaultTTSServicePopUpButton.target = self; self.defaultTTSServicePopUpButton.action = @selector(defaultTTSServicePopUpButtonClicked:); - NSTextField *mouseSelectTranslateWindowTypeLabel = [NSTextField labelWithString:NSLocalizedString(@"mouse_select_translate_window_type", nil)]; + NSTextField *mouseSelectTranslateWindowTypeLabel = [NSTextField labelWithString:EZLocalizedString(@"mouse_select_translate_window_type")]; mouseSelectTranslateWindowTypeLabel.font = font; [self.contentView addSubview:mouseSelectTranslateWindowTypeLabel]; self.mouseSelectTranslateWindowTypeLabel = mouseSelectTranslateWindowTypeLabel; @@ -363,7 +363,7 @@ - (void)setupUI { self.mouseSelectTranslateWindowTypePopUpButton.target = self; self.mouseSelectTranslateWindowTypePopUpButton.action = @selector(mouseSelectTranslateWindowTypePopUpButtonClicked:); - NSTextField *shortcutSelectTranslateWindowTypeLabel = [NSTextField labelWithString:NSLocalizedString(@"shortcut_select_translate_window_type", nil)]; + NSTextField *shortcutSelectTranslateWindowTypeLabel = [NSTextField labelWithString:EZLocalizedString(@"shortcut_select_translate_window_type")]; shortcutSelectTranslateWindowTypeLabel.font = font; [self.contentView addSubview:shortcutSelectTranslateWindowTypeLabel]; self.shortcutSelectTranslateWindowTypeLabel = shortcutSelectTranslateWindowTypeLabel; @@ -377,7 +377,7 @@ - (void)setupUI { self.shortcutSelectTranslateWindowTypePopUpButton.action = @selector(shortcutSelectTranslateWindowTypePopUpButtonClicked:); - NSTextField *fixedWindowPositionLabel = [NSTextField labelWithString:NSLocalizedString(@"fixed_window_position", nil)]; + NSTextField *fixedWindowPositionLabel = [NSTextField labelWithString:EZLocalizedString(@"fixed_window_position")]; fixedWindowPositionLabel.font = font; [self.contentView addSubview:fixedWindowPositionLabel]; self.fixedWindowPositionLabel = fixedWindowPositionLabel; @@ -391,89 +391,89 @@ - (void)setupUI { self.fixedWindowPositionPopUpButton.action = @selector(fixedWindowPositionPopUpButtonClicked:); - NSTextField *playAudioLabel = [NSTextField labelWithString:NSLocalizedString(@"play_word_audio", nil)]; + NSTextField *playAudioLabel = [NSTextField labelWithString:EZLocalizedString(@"play_word_audio")]; playAudioLabel.font = font; [self.contentView addSubview:playAudioLabel]; self.playAudioLabel = playAudioLabel; - NSString *autoPlayAudioTitle = NSLocalizedString(@"auto_play_word_audio", nil); + NSString *autoPlayAudioTitle = EZLocalizedString(@"auto_play_word_audio"); self.autoPlayAudioButton = [NSButton checkboxWithTitle:autoPlayAudioTitle target:self action:@selector(autoPlayAudioButtonClicked:)]; [self.contentView addSubview:self.autoPlayAudioButton]; - NSString *inputFieldLabelTitle = [NSString stringWithFormat:@"%@:", NSLocalizedString(@"setting.general.input.header", nil)]; + NSString *inputFieldLabelTitle = [NSString stringWithFormat:@"%@:", EZLocalizedString(@"setting.general.input.header")]; NSTextField *inputFieldLabel = [NSTextField labelWithString:inputFieldLabelTitle]; inputFieldLabel.font = font; [self.contentView addSubview:inputFieldLabel]; self.inputFieldLabel = inputFieldLabel; - NSString *clearInputTitle = NSLocalizedString(@"clear_input_when_translating", nil); + NSString *clearInputTitle = EZLocalizedString(@"clear_input_when_translating"); self.clearInputButton = [NSButton checkboxWithTitle:clearInputTitle target:self action:@selector(clearInputButtonClicked:)]; [self.contentView addSubview:self.clearInputButton]; - NSString *keepPrevResultTitle = NSLocalizedString(@"keep_prev_result_when_selected_text_is_empty", nil); + NSString *keepPrevResultTitle = EZLocalizedString(@"keep_prev_result_when_selected_text_is_empty"); self.keepPrevResultButton = [NSButton checkboxWithTitle:keepPrevResultTitle target:self action:@selector(keepPrevResultButtonClicked:)]; [self.contentView addSubview:self.keepPrevResultButton]; - NSString *selectQueryTextWhenWindowActivateTitle = NSLocalizedString(@"select_query_text_when_window_activate", nil); + NSString *selectQueryTextWhenWindowActivateTitle = EZLocalizedString(@"select_query_text_when_window_activate"); self.selectQueryTextWhenWindowActivateButton = [NSButton checkboxWithTitle:selectQueryTextWhenWindowActivateTitle target:self action:@selector(selectQueryTextWhenWindowActivateButtonClicked:)]; [self.contentView addSubview:self.selectQueryTextWhenWindowActivateButton]; - self.automaticWordSegmentationButton = [NSButton checkboxWithTitle:NSLocalizedString(@"automatic_word_segmentation", nil) target:self action:@selector(automaticWordSegmentationButtonClicked:)]; + self.automaticWordSegmentationButton = [NSButton checkboxWithTitle:EZLocalizedString(@"automatic_word_segmentation") target:self action:@selector(automaticWordSegmentationButtonClicked:)]; [self.contentView addSubview:self.automaticWordSegmentationButton]; - self.automaticallyRemoveCodeCommentSymbolsButton = [NSButton checkboxWithTitle:NSLocalizedString(@"automatically_remove_code_comment_symbols", nil) target:self action:@selector(automaticallyRemoveCodeCommentSymbolsButtonClicked:)]; + self.automaticallyRemoveCodeCommentSymbolsButton = [NSButton checkboxWithTitle:EZLocalizedString(@"automatically_remove_code_comment_symbols") target:self action:@selector(automaticallyRemoveCodeCommentSymbolsButtonClicked:)]; [self.contentView addSubview:self.automaticallyRemoveCodeCommentSymbolsButton]; - NSTextField *autoQueryLabel = [NSTextField labelWithString:NSLocalizedString(@"auto_query", nil)]; + NSTextField *autoQueryLabel = [NSTextField labelWithString:EZLocalizedString(@"auto_query")]; autoQueryLabel.font = font; [self.contentView addSubview:autoQueryLabel]; self.autoQueryLabel = autoQueryLabel; - NSString *autoQueryOCTText = NSLocalizedString(@"auto_query_ocr_text", nil); + NSString *autoQueryOCTText = EZLocalizedString(@"auto_query_ocr_text"); self.autoQueryOCRTextButton = [NSButton checkboxWithTitle:autoQueryOCTText target:self action:@selector(autoQueryOCRTextButtonClicked:)]; [self.contentView addSubview:self.autoQueryOCRTextButton]; - NSString *autoQuerySelectedText = NSLocalizedString(@"auto_query_selected_text", nil); + NSString *autoQuerySelectedText = EZLocalizedString(@"auto_query_selected_text"); self.autoQuerySelectedTextButton = [NSButton checkboxWithTitle:autoQuerySelectedText target:self action:@selector(autoQuerySelectedTextButtonClicked:)]; [self.contentView addSubview:self.autoQuerySelectedTextButton]; - NSString *autoQueryPastedTextButton = NSLocalizedString(@"auto_query_pasted_text", nil); + NSString *autoQueryPastedTextButton = EZLocalizedString(@"auto_query_pasted_text"); self.autoQueryPastedTextButton = [NSButton checkboxWithTitle:autoQueryPastedTextButton target:self action:@selector(autoQueryPastedTextButtonClicked:)]; [self.contentView addSubview:self.autoQueryPastedTextButton]; - NSTextField *autoCopyTextLabel = [NSTextField labelWithString:NSLocalizedString(@"auto_copy_text", nil)]; + NSTextField *autoCopyTextLabel = [NSTextField labelWithString:EZLocalizedString(@"auto_copy_text")]; autoCopyTextLabel.font = font; [self.contentView addSubview:autoCopyTextLabel]; self.autoCopyTextLabel = autoCopyTextLabel; - NSString *autoCopyOCRText = NSLocalizedString(@"auto_copy_ocr_text", nil); + NSString *autoCopyOCRText = EZLocalizedString(@"auto_copy_ocr_text"); self.autoCopyOCRTextButton = [NSButton checkboxWithTitle:autoCopyOCRText target:self action:@selector(autoCopyOCRTextButtonClicked:)]; [self.contentView addSubview:self.autoCopyOCRTextButton]; - NSString *autoCopySelectedText = NSLocalizedString(@"auto_copy_selected_text", nil); + NSString *autoCopySelectedText = EZLocalizedString(@"auto_copy_selected_text"); self.autoCopySelectedTextButton = [NSButton checkboxWithTitle:autoCopySelectedText target:self action:@selector(autoCopySelectedTextButtonClicked:)]; [self.contentView addSubview:self.autoCopySelectedTextButton]; - NSString *autoCopyFirstTranslatedText = NSLocalizedString(@"auto_copy_first_translated_text", nil); + NSString *autoCopyFirstTranslatedText = EZLocalizedString(@"auto_copy_first_translated_text"); self.autoCopyFirstTranslatedTextButton = [NSButton checkboxWithTitle:autoCopyFirstTranslatedText target:self action:@selector(autoCopyFirstTranslatedTextButtonClicked:)]; [self.contentView addSubview:self.autoCopyFirstTranslatedTextButton]; - NSTextField *showQuickLinkLabel = [NSTextField labelWithString:NSLocalizedString(@"quick_link", nil)]; + NSTextField *showQuickLinkLabel = [NSTextField labelWithString:EZLocalizedString(@"quick_link")]; showQuickLinkLabel.font = font; [self.contentView addSubview:showQuickLinkLabel]; self.showQuickLinkLabel = showQuickLinkLabel; - NSString *showGoogleQuickLink = NSLocalizedString(@"show_google_quick_link", nil); + NSString *showGoogleQuickLink = EZLocalizedString(@"show_google_quick_link"); self.showGoogleQuickLinkButton = [NSButton checkboxWithTitle:showGoogleQuickLink target:self action:@selector(showGoogleQuickLinkButtonClicked:)]; [self.contentView addSubview:self.showGoogleQuickLinkButton]; - NSString *showEudicQuickLink = NSLocalizedString(@"show_eudic_quick_link", nil); + NSString *showEudicQuickLink = EZLocalizedString(@"show_eudic_quick_link"); self.showEudicQuickLinkButton = [NSButton checkboxWithTitle:showEudicQuickLink target:self action:@selector(showEudicQuickLinkButtonClicked:)]; [self.contentView addSubview:self.showEudicQuickLinkButton]; - NSString *showAppleDictionaryQuickLink = NSLocalizedString(@"show_apple_dictionary_quick_link", nil); + NSString *showAppleDictionaryQuickLink = EZLocalizedString(@"show_apple_dictionary_quick_link"); self.showAppleDictionaryQuickLinkButton = [NSButton checkboxWithTitle:showAppleDictionaryQuickLink target:self action:@selector(showAppleDictionaryQuickLinkButtonClicked:)]; [self.contentView addSubview:self.showAppleDictionaryQuickLinkButton]; @@ -491,45 +491,45 @@ - (void)setupUI { view.layer.backgroundColor = separatorDarkColor.CGColor; }]; - NSTextField *hideMainWindowLabel = [NSTextField labelWithString:NSLocalizedString(@"show_main_window", nil)]; + NSTextField *hideMainWindowLabel = [NSTextField labelWithString:EZLocalizedString(@"show_main_window")]; hideMainWindowLabel.font = font; [self.contentView addSubview:hideMainWindowLabel]; self.hideMainWindowLabel = hideMainWindowLabel; - NSString *hideMainWindowTitle = NSLocalizedString(@"hide_main_window", nil); + NSString *hideMainWindowTitle = EZLocalizedString(@"hide_main_window"); self.hideMainWindowButton = [NSButton checkboxWithTitle:hideMainWindowTitle target:self action:@selector(hideMainWindowButtonClicked:)]; [self.contentView addSubview:self.hideMainWindowButton]; - NSTextField *launchLabel = [NSTextField labelWithString:NSLocalizedString(@"launch", nil)]; + NSTextField *launchLabel = [NSTextField labelWithString:EZLocalizedString(@"launch")]; launchLabel.font = font; [self.contentView addSubview:launchLabel]; self.launchLabel = launchLabel; - NSString *launchAtStartupTitle = NSLocalizedString(@"launch_at_startup", nil); + NSString *launchAtStartupTitle = EZLocalizedString(@"launch_at_startup"); self.launchAtStartupButton = [NSButton checkboxWithTitle:launchAtStartupTitle target:self action:@selector(launchAtStartupButtonClicked:)]; [self.contentView addSubview:self.launchAtStartupButton]; - NSTextField *menubarIconLabel = [NSTextField labelWithString:NSLocalizedString(@"menu_bar_icon", nil)]; + NSTextField *menubarIconLabel = [NSTextField labelWithString:EZLocalizedString(@"menu_bar_icon")]; menubarIconLabel.font = font; [self.contentView addSubview:menubarIconLabel]; self.menuBarIconLabel = menubarIconLabel; - NSString *hideMenuBarIcon = NSLocalizedString(@"hide_menu_bar_icon", nil); + NSString *hideMenuBarIcon = EZLocalizedString(@"hide_menu_bar_icon"); self.hideMenuBarIconButton = [NSButton checkboxWithTitle:hideMenuBarIcon target:self action:@selector(hideMenuBarIconButtonClicked:)]; [self.contentView addSubview:self.hideMenuBarIconButton]; if (@available(macOS 13.0, *)) { - NSTextField *betaNewAppLabel = [NSTextField labelWithString:NSLocalizedString(@"beta_new_app", nil)]; + NSTextField *betaNewAppLabel = [NSTextField labelWithString:EZLocalizedString(@"beta_new_app")]; betaNewAppLabel.font = font; [self.contentView addSubview:betaNewAppLabel]; self.betaNewAppLabel = betaNewAppLabel; - NSString *enableBetaNewApp = NSLocalizedString(@"enable_beta_new_app", nil); + NSString *enableBetaNewApp = EZLocalizedString(@"enable_beta_new_app"); self.enableBetaNewAppButton = [NSButton checkboxWithTitle:enableBetaNewApp target:self action:@selector(enableBetaNewAppButtonClicked:)]; [self.contentView addSubview:self.enableBetaNewAppButton]; } - NSTextField *fontSizeLabel = [NSTextField labelWithString:NSLocalizedString(@"font_size", nil)]; + NSTextField *fontSizeLabel = [NSTextField labelWithString:EZLocalizedString(@"font_size")]; fontSizeLabel.font = font; [self.contentView addSubview:fontSizeLabel]; self.fontSizeLabel = fontSizeLabel; @@ -556,7 +556,7 @@ - (void)setupUI { self.clickQueryButton.mm_isOn = self.config.clickQuery; self.adjustQueryIconPostionButton.mm_isOn = self.config.adjustPopButtomOrigin; [self.languageDetectOptimizePopUpButton selectItemAtIndex:self.config.languageDetectOptimize]; - [self.defaultTTSServicePopUpButton selectItemWithTitle:NSLocalizedString(self.config.defaultTTSServiceType, nil)]; + [self.defaultTTSServicePopUpButton selectItemWithTitle:EZLocalizedString(self.config.defaultTTSServiceType)]; MMOrderedDictionary *translateWindowTypeDict = [EZEnumTypes translateWindowTypeDict]; NSString *mouseWindowTitle = [translateWindowTypeDict objectForKey:@(self.config.mouseSelectTranslateWindowType)]; @@ -968,10 +968,10 @@ - (void)autoSelectTextButtonClicked:(NSButton *)sender { - (void)forceGetSelectedTextButtonClicked:(NSButton *)sender { if (sender.mm_isOn) { NSAlert *alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle:NSLocalizedString(@"ok", nil)]; - [alert addButtonWithTitle:NSLocalizedString(@"cancel", nil)]; - alert.messageText = NSLocalizedString(@"force_auto_get_selected_text_title", nil); - alert.informativeText = NSLocalizedString(@"force_auto_get_selected_text_msg", nil); + [alert addButtonWithTitle:EZLocalizedString(@"ok")]; + [alert addButtonWithTitle:EZLocalizedString(@"cancel")]; + alert.messageText = EZLocalizedString(@"force_auto_get_selected_text_title"); + alert.informativeText = EZLocalizedString(@"force_auto_get_selected_text_msg"); [alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) { if (returnCode == NSAlertFirstButtonReturn) { sender.mm_isOn = YES; @@ -1068,19 +1068,19 @@ - (void)hideMenuBarIconButtonClicked:(NSButton *)sender { self.inputShortcutView.shortcutValue == nil) { sender.mm_isOn = NO; NSAlert *alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle:NSLocalizedString(@"ok", nil)]; - alert.messageText = NSLocalizedString(@"hide_menu_bar_icon", nil); - alert.informativeText = NSLocalizedString(@"refuse_hide_menu_bar_icon_msg", nil); + [alert addButtonWithTitle:EZLocalizedString(@"ok")]; + alert.messageText = EZLocalizedString(@"hide_menu_bar_icon"); + alert.informativeText = EZLocalizedString(@"refuse_hide_menu_bar_icon_msg"); [alert beginSheetModalForWindow:[self window] completionHandler:nil]; return; } // !!!: EZFloatingWindowLevel shouldn't be higher than kCGModalPanelWindowLevel (8) if (sender.mm_isOn) { NSAlert *alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle:NSLocalizedString(@"ok", nil)]; - [alert addButtonWithTitle:NSLocalizedString(@"cancel", nil)]; - alert.messageText = NSLocalizedString(@"hide_menu_bar_icon", nil); - alert.informativeText = NSLocalizedString(@"hide_menu_bar_icon_msg", nil); + [alert addButtonWithTitle:EZLocalizedString(@"ok")]; + [alert addButtonWithTitle:EZLocalizedString(@"cancel")]; + alert.messageText = EZLocalizedString(@"hide_menu_bar_icon"); + alert.informativeText = EZLocalizedString(@"hide_menu_bar_icon_msg"); [alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) { // ok, hide icon if (returnCode == NSAlertFirstButtonReturn) { @@ -1154,9 +1154,9 @@ - (void)secondLangaugePopUpButtonClicked:(NSPopUpButton *)button { - (void)checkIfEqualFirstLanguage:(BOOL)fistLanguageFlag { if ([self.config.firstLanguage isEqualToString:self.config.secondLanguage]) { NSAlert *alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle:NSLocalizedString(@"ok", nil)]; + [alert addButtonWithTitle:EZLocalizedString(@"ok")]; - NSString *warningText = NSLocalizedString(@"equal_first_and_second_language", nil); + NSString *warningText = EZLocalizedString(@"equal_first_and_second_language"); NSString *showingLanguage = [EZLanguageManager.shared showingLanguageName:self.config.firstLanguage]; alert.messageText = [NSString stringWithFormat:@"%@: %@", warningText, showingLanguage]; [alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) { @@ -1198,7 +1198,7 @@ - (NSString *)viewIdentifier { } - (NSString *)toolbarItemLabel { - return NSLocalizedString(@"setting_general", nil); + return EZLocalizedString(@"setting_general"); } - (NSImage *)toolbarItemImage { diff --git a/Easydict/Feature/PerferenceWindow/ServiceViewController/EZServiceViewController.m b/Easydict/Feature/PerferenceWindow/ServiceViewController/EZServiceViewController.m index 12b08a613..582714f6d 100644 --- a/Easydict/Feature/PerferenceWindow/ServiceViewController/EZServiceViewController.m +++ b/Easydict/Feature/PerferenceWindow/ServiceViewController/EZServiceViewController.m @@ -126,9 +126,9 @@ - (NSSegmentedControl *)segmentedControl { NSSegmentedControl *segmentedControl = [[NSSegmentedControl alloc] init]; [self.view addSubview:segmentedControl]; [segmentedControl setSegmentCount:3]; - [segmentedControl setLabel:NSLocalizedString(@"mini_window", nil) forSegment:0]; - [segmentedControl setLabel:NSLocalizedString(@"fixed_window", nil) forSegment:1]; - [segmentedControl setLabel:NSLocalizedString(@"main_window", nil) forSegment:2]; + [segmentedControl setLabel:EZLocalizedString(@"mini_window") forSegment:0]; + [segmentedControl setLabel:EZLocalizedString(@"fixed_window") forSegment:1]; + [segmentedControl setLabel:EZLocalizedString(@"main_window") forSegment:2]; [segmentedControl setTarget:self]; [segmentedControl setAction:@selector(segmentedControlClicked:)]; [segmentedControl setSelectedSegment:0]; @@ -332,7 +332,7 @@ - (NSString *)viewIdentifier { } - (NSString *)toolbarItemLabel { - return NSLocalizedString(@"service", nil); + return EZLocalizedString(@"service"); } - (NSImage *)toolbarItemImage { diff --git a/Easydict/Feature/Service/Ali/AliService.swift b/Easydict/Feature/Service/Ali/AliService.swift index d8101cc4a..edc3b9a3a 100644 --- a/Easydict/Feature/Service/Ali/AliService.swift +++ b/Easydict/Feature/Service/Ali/AliService.swift @@ -22,7 +22,7 @@ class AliService: QueryService { } override public func name() -> String { - NSLocalizedString("ali_translate", comment: "The name of Ali Translate") + NSLocalizedString("ali_translate", bundle: localizedBundle, comment: "The name of Ali Translate") } override public func supportLanguagesDictionary() -> MMOrderedDictionary { diff --git a/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m b/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m index bb4a793a9..a61628f82 100644 --- a/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m +++ b/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m @@ -12,6 +12,7 @@ #import "NSString+EZUtils.h" #import "NSString+EZHandleInputText.h" #import "NSString+EZChineseText.h" +#import "Easydict-Swift.h" @implementation EZAppleDictionary @@ -46,7 +47,7 @@ - (nullable NSString *)wordLink:(EZQueryModel *)queryModel { } - (NSString *)name { - return NSLocalizedString(@"apple_dictionary", nil); + return EZLocalizedString(@"apple_dictionary"); } - (MMOrderedDictionary *)supportLanguagesDictionary { diff --git a/Easydict/Feature/Service/Apple/EZAppleService.m b/Easydict/Feature/Service/Apple/EZAppleService.m index cfad04389..ae09cb5bb 100644 --- a/Easydict/Feature/Service/Apple/EZAppleService.m +++ b/Easydict/Feature/Service/Apple/EZAppleService.m @@ -181,7 +181,7 @@ - (EZServiceType)serviceType { } - (NSString *)name { - return NSLocalizedString(@"apple_translate", nil); + return EZLocalizedString(@"apple_translate"); } - (MMOrderedDictionary *)supportLanguagesDictionary { @@ -811,7 +811,7 @@ - (void)ocrImage:(NSImage *)image [self ocrImage:image language:tryLanguage autoDetect:YES completion:completion]; return; } else { - error = [EZError errorWithType:EZErrorTypeAPI description:NSLocalizedString(@"ocr_result_is_empty", nil)]; + error = [EZError errorWithType:EZErrorTypeAPI description:EZLocalizedString(@"ocr_result_is_empty")]; // We try to use Japanese before, but failed, so need to reset to auto. ocrResult.from = EZLanguageAuto; diff --git a/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m b/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m index 726add2ad..f0a2dbb0d 100644 --- a/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m +++ b/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m @@ -139,7 +139,7 @@ - (EZQueryTextType)intelligentQueryTextType { } - (NSString *)name { - return NSLocalizedString(@"baidu_translate", nil); + return EZLocalizedString(@"baidu_translate"); } - (NSString *)link { @@ -545,7 +545,7 @@ - (void)parseResponseObject:(id _Nullable)responseObject completion:(nonnull voi if (symbol.ph_am.length) { [phonetics addObject:[EZWordPhonetic mm_anyMake:^(EZWordPhonetic *_Nonnull obj) { - obj.name = NSLocalizedString(@"us_phonetic", nil); + obj.name = EZLocalizedString(@"us_phonetic"); obj.language = language; obj.accent = @"us"; obj.word = text; @@ -555,7 +555,7 @@ - (void)parseResponseObject:(id _Nullable)responseObject completion:(nonnull voi } if (symbol.ph_en.length) { [phonetics addObject:[EZWordPhonetic mm_anyMake:^(EZWordPhonetic *_Nonnull obj) { - obj.name = NSLocalizedString(@"uk_phonetic", nil); + obj.name = EZLocalizedString(@"uk_phonetic"); obj.language = language; obj.accent = @"uk"; obj.word = text; @@ -587,49 +587,49 @@ - (void)parseResponseObject:(id _Nullable)responseObject completion:(nonnull voi NSMutableArray *exchanges = [NSMutableArray array]; if (exchange.word_third.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"singular", nil); + obj.name = EZLocalizedString(@"singular"); obj.words = exchange.word_third; }]]; } if (exchange.word_pl.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"plural", nil); + obj.name = EZLocalizedString(@"plural"); obj.words = exchange.word_pl; }]]; } if (exchange.word_er.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"comparative", nil); + obj.name = EZLocalizedString(@"comparative"); obj.words = exchange.word_er; }]]; } if (exchange.word_est.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"superlative", nil); + obj.name = EZLocalizedString(@"superlative"); obj.words = exchange.word_est; }]]; } if (exchange.word_past.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"past", nil); + obj.name = EZLocalizedString(@"past"); obj.words = exchange.word_past; }]]; } if (exchange.word_done.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"past_participle", nil); + obj.name = EZLocalizedString(@"past_participle"); obj.words = exchange.word_done; }]]; } if (exchange.word_ing.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"present_participle", nil); + obj.name = EZLocalizedString(@"present_participle"); obj.words = exchange.word_ing; }]]; } if (exchange.word_proto.count) { [exchanges addObject:[EZTranslateExchange mm_anyMake:^(EZTranslateExchange *_Nonnull obj) { - obj.name = NSLocalizedString(@"root", nil); + obj.name = EZLocalizedString(@"root"); obj.words = exchange.word_proto; }]]; } diff --git a/Easydict/Feature/Service/Bing/EZBingService.m b/Easydict/Feature/Service/Bing/EZBingService.m index 5483b8200..94d7a8f69 100644 --- a/Easydict/Feature/Service/Bing/EZBingService.m +++ b/Easydict/Feature/Service/Bing/EZBingService.m @@ -179,7 +179,7 @@ - (nullable NSString *)wordLink:(EZQueryModel *)queryModel { } - (NSString *)name { - return NSLocalizedString(@"bing_translate", nil); + return EZLocalizedString(@"bing_translate"); } - (EZServiceType)serviceType { @@ -253,7 +253,7 @@ - (nullable NSError *)processTranslateResult:(NSData *)translateData text:(NSStr EZWordPhonetic *phonetic = [EZWordPhonetic new]; EZLanguage fromLanguage = self.result.queryFromLanguage; - phonetic.name = [fromLanguage isEqualToString:EZLanguageEnglish] ? NSLocalizedString(@"us_phonetic", nil) : NSLocalizedString(@"chinese_phonetic", nil); + phonetic.name = [fromLanguage isEqualToString:EZLanguageEnglish] ? EZLocalizedString(@"us_phonetic") : EZLocalizedString(@"chinese_phonetic"); // If text is too long, we don't show phonetic. if (![EZLanguageManager.shared isShortWordLength:text language:fromLanguage]) { @@ -376,7 +376,7 @@ - (void)parseBingDictTranslate:(NSDictionary *)json word:(NSString *)word comple EZWordPhonetic *phonetic = [EZWordPhonetic new]; phonetic.word = word; phonetic.language = EZLanguageEnglish; - phonetic.name = [name isEqualToString:@"US"] ? NSLocalizedString(@"us_phonetic", nil) : NSLocalizedString(@"uk_phonetic", nil); + phonetic.name = [name isEqualToString:@"US"] ? EZLocalizedString(@"us_phonetic") : EZLocalizedString(@"uk_phonetic"); phonetic.value = fragments.firstObject[@"text"]; phonetic.speakURL = [name isEqualToString:@"US"] ? usAudioUrl : [usAudioUrl stringByReplacingOccurrencesOfString:@"tom" withString:@"george"]; phonetic.accent = name; diff --git a/Easydict/Feature/Service/Caiyun/CaiyunService.swift b/Easydict/Feature/Service/Caiyun/CaiyunService.swift index 0451955c5..0bfb52582 100644 --- a/Easydict/Feature/Service/Caiyun/CaiyunService.swift +++ b/Easydict/Feature/Service/Caiyun/CaiyunService.swift @@ -27,7 +27,7 @@ public final class CaiyunService: QueryService { } override public func name() -> String { - NSLocalizedString("caiyun_translate", comment: "The name of Caiyun Translate") + NSLocalizedString("caiyun_translate", bundle: localizedBundle, comment: "The name of Caiyun Translate") } override public func supportLanguagesDictionary() -> MMOrderedDictionary { diff --git a/Easydict/Feature/Service/CustomOpenAI/CustomOpenAIService.swift b/Easydict/Feature/Service/CustomOpenAI/CustomOpenAIService.swift index 653e02bab..076733ed3 100644 --- a/Easydict/Feature/Service/CustomOpenAI/CustomOpenAIService.swift +++ b/Easydict/Feature/Service/CustomOpenAI/CustomOpenAIService.swift @@ -26,7 +26,7 @@ class CustomOpenAIService: OpenAILikeService { if let name, !name.isEmpty { return name } - return NSLocalizedString("custom_openai", comment: "The name of Custom OpenAI Translate") + return "custom_openai".localized } // MARK: Internal diff --git a/Easydict/Feature/Service/DeepL/EZDeepLTranslate.m b/Easydict/Feature/Service/DeepL/EZDeepLTranslate.m index 576c5de8c..991c7637c 100644 --- a/Easydict/Feature/Service/DeepL/EZDeepLTranslate.m +++ b/Easydict/Feature/Service/DeepL/EZDeepLTranslate.m @@ -10,6 +10,7 @@ #import "EZWebViewTranslator.h" #import "EZError.h" #import "EZQueryResult+EZDeepLTranslateResponse.h" +#import "Easydict-Swift.h" static NSString *kDeepLTranslateURL = @"https://www.deepl.com/translator"; @@ -67,7 +68,7 @@ - (EZServiceType)serviceType { } - (NSString *)name { - return NSLocalizedString(@"deepL_translate", nil); + return EZLocalizedString(@"deepL_translate"); } - (NSString *)link { diff --git a/Easydict/Feature/Service/Gemini/GeminiService.swift b/Easydict/Feature/Service/Gemini/GeminiService.swift index 0afa38a9f..01ea1a133 100644 --- a/Easydict/Feature/Service/Gemini/GeminiService.swift +++ b/Easydict/Feature/Service/Gemini/GeminiService.swift @@ -25,7 +25,7 @@ public final class GeminiService: QueryService { } override public func name() -> String { - NSLocalizedString("gemini_translate", comment: "The name of Gemini Translate") + NSLocalizedString("gemini_translate", bundle: localizedBundle, comment: "The name of Gemini Translate") } override public func supportLanguagesDictionary() -> MMOrderedDictionary { diff --git a/Easydict/Feature/Service/Google/EZGoogleTranslate.m b/Easydict/Feature/Service/Google/EZGoogleTranslate.m index f2af0a9ae..9c6f18ef4 100644 --- a/Easydict/Feature/Service/Google/EZGoogleTranslate.m +++ b/Easydict/Feature/Service/Google/EZGoogleTranslate.m @@ -121,7 +121,7 @@ - (EZQueryTextType)intelligentQueryTextType { } - (NSString *)name { - return NSLocalizedString(@"google_translate", nil); + return EZLocalizedString(@"google_translate"); } - (NSString *)link { @@ -363,9 +363,9 @@ - (void)webApptranslate:(NSString *)text from:(EZLanguage)from to:(EZLanguage)to wordResult = [[EZTranslateWordResult alloc] init]; EZWordPhonetic *phonetic = [[EZWordPhonetic alloc] init]; - phonetic.name = NSLocalizedString(@"us_phonetic", nil); + phonetic.name = EZLocalizedString(@"us_phonetic"); if ([EZLanguageManager.shared isChineseLanguage:from]) { - phonetic.name = NSLocalizedString(@"chinese_phonetic", nil); + phonetic.name = EZLocalizedString(@"chinese_phonetic"); } phonetic.value = phoneticText; diff --git a/Easydict/Feature/Service/Language/EZLanguageManager.m b/Easydict/Feature/Service/Language/EZLanguageManager.m index 6650763d5..29b69f511 100644 --- a/Easydict/Feature/Service/Language/EZLanguageManager.m +++ b/Easydict/Feature/Service/Language/EZLanguageManager.m @@ -355,7 +355,7 @@ - (NSString *)languageLocalName:(EZLanguage)language { /// Showing language name according user first language, Chinese: English -> 英语, English: English -> English. - (NSString *)showingLanguageName:(EZLanguage)language { NSString *languageName = language ?: EZLanguageAuto; - if ([self isSystemChineseFirstLanguage]) { + if (EZI18nHelper.shared.isSimplifiedChineseLocalize) { languageName = [self languageChineseName:language]; } else { if ([language isEqualToString:EZLanguageAuto]) { diff --git a/Easydict/Feature/Service/Model/EZEnumTypes.m b/Easydict/Feature/Service/Model/EZEnumTypes.m index adeb7149b..8553042fc 100644 --- a/Easydict/Feature/Service/Model/EZEnumTypes.m +++ b/Easydict/Feature/Service/Model/EZEnumTypes.m @@ -80,10 +80,10 @@ + (NSString *)windowName:(EZWindowType)type { + (MMOrderedDictionary *)fixedWindowPositionDict { MMOrderedDictionary *dict = [[MMOrderedDictionary alloc] initWithKeysAndObjects: - @(EZShowWindowPositionRight), NSLocalizedString(@"fixed_window_position_right", nil), - @(EZShowWindowPositionMouse), NSLocalizedString(@"fixed_window_position_mouse", nil), - @(EZShowWindowPositionFormer), NSLocalizedString(@"fixed_window_position_former", nil), - @(EZShowWindowPositionCenter), NSLocalizedString(@"fixed_window_position_center", nil), + @(EZShowWindowPositionRight), EZLocalizedString(@"fixed_window_position_right"), + @(EZShowWindowPositionMouse), EZLocalizedString(@"fixed_window_position_mouse"), + @(EZShowWindowPositionFormer), EZLocalizedString(@"fixed_window_position_former"), + @(EZShowWindowPositionCenter), EZLocalizedString(@"fixed_window_position_center"), nil]; return dict; @@ -91,8 +91,8 @@ + (NSString *)windowName:(EZWindowType)type { + (MMOrderedDictionary *)translateWindowTypeDict { MMOrderedDictionary *dict = [[MMOrderedDictionary alloc] initWithKeysAndObjects: - @(EZWindowTypeMini), NSLocalizedString(@"mini_window", nil), - @(EZWindowTypeFixed), NSLocalizedString(@"fixed_window", nil), + @(EZWindowTypeMini), EZLocalizedString(@"mini_window"), + @(EZWindowTypeFixed), EZLocalizedString(@"fixed_window"), nil]; return dict; diff --git a/Easydict/Feature/Service/Model/EZError.m b/Easydict/Feature/Service/Model/EZError.m index 51d3daa95..65cf0077c 100644 --- a/Easydict/Feature/Service/Model/EZError.m +++ b/Easydict/Feature/Service/Model/EZError.m @@ -61,30 +61,30 @@ + (instancetype)errorWithType:(EZErrorType)type errorString = @"None"; break; case EZErrorTypeParam: - errorString = NSLocalizedString(@"error_parameter", nil); + errorString = EZLocalizedString(@"error_parameter"); break; case EZErrorTypeNetwork: - errorString = NSLocalizedString(@"error_network", nil); + errorString = EZLocalizedString(@"error_network"); break; case EZErrorTypeAPI: - errorString = NSLocalizedString(@"error_api", nil); + errorString = EZLocalizedString(@"error_api"); break; case EZErrorTypeUnsupportedLanguage: - errorString = NSLocalizedString(@"error_unsupport_language", nil); + errorString = EZLocalizedString(@"error_unsupport_language"); break; case EZErrorTypeNoResultsFound: - errorString = NSLocalizedString(@"no_results_found", nil); + errorString = EZLocalizedString(@"no_results_found"); break; case EZErrorTypeInsufficientQuota: - errorString = NSLocalizedString(@"error_insufficient_quota", nil); + errorString = EZLocalizedString(@"error_insufficient_quota"); break; default: - errorString = NSLocalizedString(@"error_unknown", nil); + errorString = EZLocalizedString(@"error_unknown"); break; } - NSString *queryFailedString = NSLocalizedString(@"query_failed", nil); + NSString *queryFailedString = EZLocalizedString(@"query_failed"); if (errorString.length) { errorString = [NSString stringWithFormat:@"%@, %@", queryFailedString, errorString]; } diff --git a/Easydict/Feature/Service/Model/EZQueryService.m b/Easydict/Feature/Service/Model/EZQueryService.m index f73bd5275..0600b6d5e 100644 --- a/Easydict/Feature/Service/Model/EZQueryService.m +++ b/Easydict/Feature/Service/Model/EZQueryService.m @@ -196,7 +196,7 @@ - (BOOL)prehandleQueryTextLanguage:(NSString *)text if (self.needPrivateAPIKey && !self.hasPrivateAPIKey && ![EZLocalStorage.shared hasFreeQuotaLeft:self]) { EZError *error = [EZError errorWithType:EZErrorTypeInsufficientQuota description:nil - errorDataMessage:NSLocalizedString(@"insufficient_quota_prompt", nil)]; + errorDataMessage:EZLocalizedString(@"insufficient_quota_prompt")]; self.result.promptURL = self.link; completion(self.result, error); diff --git a/Easydict/Feature/Service/Niutrans/EZNiuTransTranslate.m b/Easydict/Feature/Service/Niutrans/EZNiuTransTranslate.m index 133b471c5..5450d1f16 100644 --- a/Easydict/Feature/Service/Niutrans/EZNiuTransTranslate.m +++ b/Easydict/Feature/Service/Niutrans/EZNiuTransTranslate.m @@ -44,7 +44,7 @@ - (EZServiceType)serviceType { } - (NSString *)name { - return NSLocalizedString(@"niuTrans_translate", nil); + return EZLocalizedString(@"niuTrans_translate"); } - (NSString *)link { diff --git a/Easydict/Feature/Service/OpenAI/EZOpenAIService.m b/Easydict/Feature/Service/OpenAI/EZOpenAIService.m index 986758bc8..f08c748c7 100644 --- a/Easydict/Feature/Service/OpenAI/EZOpenAIService.m +++ b/Easydict/Feature/Service/OpenAI/EZOpenAIService.m @@ -100,7 +100,7 @@ - (EZServiceUsageStatus)serviceUsageStatus { } - (NSString *)name { - return NSLocalizedString(@"openai_translate", nil); + return EZLocalizedString(@"openai_translate"); } - (NSString *)link { diff --git a/Easydict/Feature/Service/Tencent/TencentService.swift b/Easydict/Feature/Service/Tencent/TencentService.swift index 4be03aa57..fd189b2af 100644 --- a/Easydict/Feature/Service/Tencent/TencentService.swift +++ b/Easydict/Feature/Service/Tencent/TencentService.swift @@ -23,7 +23,7 @@ public final class TencentService: QueryService { } override public func name() -> String { - NSLocalizedString("tencent_translate", comment: "The name of Tencent Translate") + NSLocalizedString("tencent_translate", bundle: localizedBundle, comment: "The name of Tencent Translate") } override public func supportLanguagesDictionary() -> MMOrderedDictionary { diff --git a/Easydict/Feature/Service/Volcano/EZVolcanoTranslate.m b/Easydict/Feature/Service/Volcano/EZVolcanoTranslate.m index d70fd5565..a320a880e 100644 --- a/Easydict/Feature/Service/Volcano/EZVolcanoTranslate.m +++ b/Easydict/Feature/Service/Volcano/EZVolcanoTranslate.m @@ -8,6 +8,7 @@ #import "EZVolcanoTranslate.h" #import "EZWebViewTranslator.h" +#import "Easydict-Swift.h" static NSString *kVolcanoLTranslateURL = @"https://translate.volcengine.com"; @@ -57,7 +58,7 @@ - (EZServiceType)serviceType { } - (NSString *)name { - return NSLocalizedString(@"volcano_translate", nil); + return EZLocalizedString(@"volcano_translate"); } - (NSString *)link { diff --git a/Easydict/Feature/Service/Youdao/EZQueryResult+EZYoudaoDictModel.m b/Easydict/Feature/Service/Youdao/EZQueryResult+EZYoudaoDictModel.m index be590f059..e2a17f5aa 100644 --- a/Easydict/Feature/Service/Youdao/EZQueryResult+EZYoudaoDictModel.m +++ b/Easydict/Feature/Service/Youdao/EZQueryResult+EZYoudaoDictModel.m @@ -27,7 +27,7 @@ - (instancetype)setupWithYoudaoDictModel:(EZYoudaoDictModel *)model { NSString *aduioURL = @"https://dict.youdao.com/dictvoice?audio="; if (word.usphone) { EZWordPhonetic *phonetic = [[EZWordPhonetic alloc] init]; - phonetic.name = NSLocalizedString(@"us_phonetic", nil); + phonetic.name = EZLocalizedString(@"us_phonetic"); phonetic.language = language; phonetic.accent = @"us"; phonetic.word = self.queryText; @@ -42,7 +42,7 @@ - (instancetype)setupWithYoudaoDictModel:(EZYoudaoDictModel *)model { } if (word.ukphone) { EZWordPhonetic *phonetic = [[EZWordPhonetic alloc] init]; - phonetic.name = NSLocalizedString(@"uk_phonetic", nil); + phonetic.name = EZLocalizedString(@"uk_phonetic"); phonetic.language = language; phonetic.accent = @"uk"; phonetic.word = self.queryText; @@ -105,7 +105,7 @@ - (instancetype)setupWithYoudaoDictModel:(EZYoudaoDictModel *)model { EZWordPhonetic *phonetic = [[EZWordPhonetic alloc] init]; phonetic.word = self.queryText; phonetic.language = language; - phonetic.name = NSLocalizedString(@"chinese_phonetic", nil); + phonetic.name = EZLocalizedString(@"chinese_phonetic"); phonetic.value = word.phone; // ɡʊd [phoneticArray addObject:phonetic]; } diff --git a/Easydict/Feature/Service/Youdao/EZYoudaoTranslate.m b/Easydict/Feature/Service/Youdao/EZYoudaoTranslate.m index 3c9f476b4..0e0730ac5 100644 --- a/Easydict/Feature/Service/Youdao/EZYoudaoTranslate.m +++ b/Easydict/Feature/Service/Youdao/EZYoudaoTranslate.m @@ -179,7 +179,7 @@ - (EZQueryTextType)intelligentQueryTextType { } - (NSString *)name { - return NSLocalizedString(@"youdao_dict", nil); + return EZLocalizedString(@"youdao_dict"); } - (NSString *)link { @@ -675,7 +675,7 @@ - (void)youdaoAIDemoTranslate:(NSString *)text from:(EZLanguage)from to:(EZLangu NSMutableArray *phoneticArray = [NSMutableArray array]; if (basic.us_phonetic && basic.us_speech) { EZWordPhonetic *phonetic = [EZWordPhonetic new]; - phonetic.name = NSLocalizedString(@"us_phonetic", nil); + phonetic.name = EZLocalizedString(@"us_phonetic"); phonetic.language = language; phonetic.accent = @"us"; phonetic.value = basic.us_phonetic; @@ -684,7 +684,7 @@ - (void)youdaoAIDemoTranslate:(NSString *)text from:(EZLanguage)from to:(EZLangu } if (basic.uk_phonetic && basic.uk_speech) { EZWordPhonetic *phonetic = [EZWordPhonetic new]; - phonetic.name = NSLocalizedString(@"uk_phonetic", nil); + phonetic.name = EZLocalizedString(@"uk_phonetic"); phonetic.language = language; phonetic.accent = @"uk"; phonetic.value = basic.uk_phonetic; diff --git a/Easydict/Feature/Utility/EZCategory/NSObject+EZWindowType.m b/Easydict/Feature/Utility/EZCategory/NSObject+EZWindowType.m index 48567504a..a1ae71f4c 100644 --- a/Easydict/Feature/Utility/EZCategory/NSObject+EZWindowType.m +++ b/Easydict/Feature/Utility/EZCategory/NSObject+EZWindowType.m @@ -8,16 +8,16 @@ #import "NSObject+EZWindowType.h" -static NSString *EZWindowTypeKey = @"EZWindowTypeKey"; +static NSString *_EZWindowTypeKey = @"EZWindowTypeKey"; @implementation NSObject (EZWindowType) - (void)setWindowType:(EZWindowType)windowType { - objc_setAssociatedObject(self, (__bridge const void *)(EZWindowTypeKey), @(windowType), OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject(self, (__bridge const void *)(_EZWindowTypeKey), @(windowType), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (EZWindowType)windowType { - return [objc_getAssociatedObject(self, (__bridge const void *)(EZWindowTypeKey)) integerValue]; + return [objc_getAssociatedObject(self, (__bridge const void *)(_EZWindowTypeKey)) integerValue]; } @end diff --git a/Easydict/Feature/ViewController/Cell/EZSelectLanguageCell.m b/Easydict/Feature/ViewController/Cell/EZSelectLanguageCell.m index 1be65ee65..eb15529f1 100644 --- a/Easydict/Feature/ViewController/Cell/EZSelectLanguageCell.m +++ b/Easydict/Feature/ViewController/Cell/EZSelectLanguageCell.m @@ -62,7 +62,7 @@ - (void)setup { self.transformButton = transformButton; [languageBarView addSubview:transformButton]; NSString *shortcut = @"⌘+T"; - NSString *toolTip = [NSString stringWithFormat:@"%@, %@", NSLocalizedString(@"toggle_languages", nil), shortcut]; + NSString *toolTip = [NSString stringWithFormat:@"%@, %@", EZLocalizedString(@"toggle_languages"), shortcut]; transformButton.toolTip = toolTip; transformButton.image = [NSImage imageNamed:@"transform"]; diff --git a/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift b/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift index d0c77cf21..7228a7ba6 100644 --- a/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift +++ b/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift @@ -48,10 +48,19 @@ public class FontSizeHintView: NSView { // MARK: Private - private lazy var minLabel: NSTextField = .init(labelWithString: NSLocalizedString("small", comment: "")) - private lazy var maxLabel: NSTextField = .init(labelWithString: NSLocalizedString("large", comment: "")) + private lazy var minLabel: NSTextField = .init(labelWithString: NSLocalizedString( + "small", + bundle: localizedBundle, + comment: "" + )) + private lazy var maxLabel: NSTextField = .init(labelWithString: NSLocalizedString( + "large", + bundle: localizedBundle, + comment: "" + )) private lazy var hintLabel: NSTextField = .init(wrappingLabelWithString: NSLocalizedString( "hints_keyboard_shortcuts_font_size", + bundle: localizedBundle, comment: "" )) } diff --git a/Easydict/Feature/ViewController/View/CustomButton/EZCopyButton/EZCopyButton.m b/Easydict/Feature/ViewController/View/CustomButton/EZCopyButton/EZCopyButton.m index 0bc5d29e9..86395497d 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/EZCopyButton/EZCopyButton.m +++ b/Easydict/Feature/ViewController/View/CustomButton/EZCopyButton/EZCopyButton.m @@ -29,7 +29,7 @@ - (void)setup { button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]]; }]; - NSString *action = NSLocalizedString(@"copy_text", nil); + NSString *action = EZLocalizedString(@"copy_text"); self.toolTip = [NSString stringWithFormat:@"%@", action]; } diff --git a/Easydict/Feature/ViewController/View/CustomButton/EZReplaceTextButton/EZReplaceTextButton.m b/Easydict/Feature/ViewController/View/CustomButton/EZReplaceTextButton/EZReplaceTextButton.m index 749219256..8023adaca 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/EZReplaceTextButton/EZReplaceTextButton.m +++ b/Easydict/Feature/ViewController/View/CustomButton/EZReplaceTextButton/EZReplaceTextButton.m @@ -30,7 +30,8 @@ - (void)setup { button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]]; }]; - NSString *action = NSLocalizedString(@"replace_text", nil); + + NSString *action = EZLocalizedString(@"replace_text"); self.toolTip = [NSString stringWithFormat:@"%@", action]; } diff --git a/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZDetectLanguageButton.m b/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZDetectLanguageButton.m index d755df264..638c039b4 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZDetectLanguageButton.m +++ b/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZDetectLanguageButton.m @@ -9,6 +9,7 @@ #import "EZDetectLanguageButton.h" #import "EZLanguageManager.h" #import "NSView+EZAnimatedHidden.h" +#import "Easydict-Swift.h" @interface EZDetectLanguageButton () @@ -64,7 +65,7 @@ - (void)setDetectedLanguage:(EZLanguage)detectedLanguage { NSString *detectLanguageTitle = [EZLanguageManager.shared showingLanguageName:detectedLanguage]; - NSString *title = NSLocalizedString(@"detected", nil); + NSString *title = EZLocalizedString(@"detected"); NSMutableAttributedString *attrTitle = [[NSMutableAttributedString alloc] initWithString:title]; [attrTitle addAttributes:@{ NSForegroundColorAttributeName : NSColor.grayColor, diff --git a/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZSelectLanguageButton.m b/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZSelectLanguageButton.m index faa8b1e83..c3a8eb9cf 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZSelectLanguageButton.m +++ b/Easydict/Feature/ViewController/View/CustomButton/LanguageButton/EZSelectLanguageButton.m @@ -117,7 +117,7 @@ - (void)setupMenu { NSString *languageFlag = [languageManager languageFlagEmoji:language]; if ([language isEqualToString:EZLanguageAuto]) { - if ([languageManager isSystemChineseFirstLanguage] && self.autoChineseSelectedTitle.length) { + if (EZI18nHelper.shared.isSimplifiedChineseLocalize && self.autoChineseSelectedTitle.length) { languageName = self.autoChineseSelectedTitle; } } @@ -170,7 +170,7 @@ - (void)setSelectedLanguage:(EZLanguage)selectedLanguage { NSString *toolTip = nil; if ([selectedLanguage isEqualToString:EZLanguageAuto]) { - if ([languageManager isSystemChineseFirstLanguage] && self.autoChineseSelectedTitle.length) { + if (EZI18nHelper.shared.isSimplifiedChineseLocalize && self.autoChineseSelectedTitle.length) { languageName = self.autoChineseSelectedTitle; } languageFlag = [languageManager languageFlagEmoji:self.autoSelectedLanguage]; diff --git a/Easydict/Feature/ViewController/View/EZQueryMenuTextView/EZQueryMenuTextView.m b/Easydict/Feature/ViewController/View/EZQueryMenuTextView/EZQueryMenuTextView.m index ab46a8a8b..5c2d3920e 100644 --- a/Easydict/Feature/ViewController/View/EZQueryMenuTextView/EZQueryMenuTextView.m +++ b/Easydict/Feature/ViewController/View/EZQueryMenuTextView/EZQueryMenuTextView.m @@ -31,7 +31,7 @@ - (NSMenu *)menuForEvent:(NSEvent *)event { NSString *queryText = [self selectedText].trim; if (queryText.length > 0) { - NSString *title = [NSString stringWithFormat:@"%@ \"%@\"", NSLocalizedString(@"query_in_app", nil), queryText]; + NSString *title = [NSString stringWithFormat:@"%@ \"%@\"", EZLocalizedString(@"query_in_app"), queryText]; NSMenuItem *queryInAppMenuItem = [[NSMenuItem alloc] initWithTitle:title action:@selector(queryInApp:) keyEquivalent:@""]; // Note that this shortcut only works when the menu is displayed. diff --git a/Easydict/Feature/ViewController/View/QueryView/EZQueryView.m b/Easydict/Feature/ViewController/View/QueryView/EZQueryView.m index a99a4d73a..5ce21ce1f 100644 --- a/Easydict/Feature/ViewController/View/QueryView/EZQueryView.m +++ b/Easydict/Feature/ViewController/View/QueryView/EZQueryView.m @@ -110,7 +110,7 @@ - (void)setup { self.audioButton = audioButton; [audioButton setPlayStatus:^(BOOL isPlaying, EZAudioButton *audioButton) { - NSString *action = isPlaying ? NSLocalizedString(@"stop_play_audio", nil) : NSLocalizedString(@"play_audio", nil); + NSString *action = isPlaying ? EZLocalizedString(@"stop_play_audio") : EZLocalizedString(@"play_audio"); NSString *shortcut = @"⌘+S"; audioButton.toolTip = [NSString stringWithFormat:@"%@, %@", action, shortcut]; }]; @@ -127,7 +127,7 @@ - (void)setup { [self addSubview:textCopyButton]; self.textCopyButton = textCopyButton; - NSString *copyAction = NSLocalizedString(@"copy_text", nil); + NSString *copyAction = EZLocalizedString(@"copy_text"); NSString *copyShortcut = @"⌘+⇧+C"; textCopyButton.toolTip = [NSString stringWithFormat:@"%@, %@", copyAction, copyShortcut]; @@ -165,7 +165,7 @@ - (void)setup { clearImage = [clearImage imageWithTintColor:[NSColor mm_colorWithHexString:@"#868686"]]; clearButton.image = clearImage; - NSString *clearAction = NSLocalizedString(@"clear_all", nil); + NSString *clearAction = EZLocalizedString(@"clear_all"); NSString *clearShortcut = @"⌘+⇧+K"; clearButton.toolTip = [NSString stringWithFormat:@"%@, %@", clearAction, clearShortcut]; diff --git a/Easydict/Feature/ViewController/View/ResultView/EZResultView.m b/Easydict/Feature/ViewController/View/ResultView/EZResultView.m index abdda61fc..af86327c4 100644 --- a/Easydict/Feature/ViewController/View/ResultView/EZResultView.m +++ b/Easydict/Feature/ViewController/View/ResultView/EZResultView.m @@ -185,7 +185,7 @@ - (void)setup { NSImage *retryImage = [NSImage ez_imageWithSymbolName:@"arrow.clockwise.circle"]; retryButton.image = retryImage; retryButton.mas_key = @"retryButton"; - retryButton.toolTip = NSLocalizedString(@"retry", nil); + retryButton.toolTip = EZLocalizedString(@"retry"); retryButton.hidden = YES; [retryButton excuteLight:^(NSButton *button) { button.image = [button.image imageWithTintColor:[NSColor ez_imageTintLightColor]]; @@ -385,7 +385,7 @@ - (void)updateArrowButton { arrowImage = [NSImage imageNamed:@"arrow-down"]; } - self.arrowButton.toolTip = self.result.isShowing ? NSLocalizedString(@"hide", nil) : NSLocalizedString(@"show", nil); + self.arrowButton.toolTip = self.result.isShowing ? EZLocalizedString(@"hide") : EZLocalizedString(@"show"); [self.arrowButton excuteLight:^(NSButton *button) { button.image = [arrowImage imageWithTintColor:[NSColor ez_imageTintLightColor]]; diff --git a/Easydict/Feature/ViewController/View/Titlebar/EZTitlebar.m b/Easydict/Feature/ViewController/View/Titlebar/EZTitlebar.m index a7d8f4859..991a39f24 100644 --- a/Easydict/Feature/ViewController/View/Titlebar/EZTitlebar.m +++ b/Easydict/Feature/ViewController/View/Titlebar/EZTitlebar.m @@ -152,7 +152,7 @@ - (void)updateConstraints { googleButton.link = EZGoogleWebSearchURL; googleButton.image = [[NSImage imageNamed:@"google_icon"] resizeToSize:imageSize]; - googleButton.toolTip = [NSString stringWithFormat:@"%@, %@", NSLocalizedString(@"open_in_google", nil), @" ⌘+⏎"]; + googleButton.toolTip = [NSString stringWithFormat:@"%@, %@", EZLocalizedString(@"open_in_google"), @" ⌘+⏎"]; googleButton.contentTintColor = NSColor.clearColor; [googleButton mas_remakeConstraints:^(MASConstraintMaker *make) { @@ -171,7 +171,7 @@ - (void)updateConstraints { appleDictButton.link = EZAppleDictionaryAppURLScheme; appleDictButton.image = [[NSImage imageNamed:EZServiceTypeAppleDictionary] resizeToSize:imageSize]; - appleDictButton.toolTip = [NSString stringWithFormat:@"%@, %@", NSLocalizedString(@"open_in_apple_dictionary", nil), @"⌘+⇧+D"]; + appleDictButton.toolTip = [NSString stringWithFormat:@"%@, %@", EZLocalizedString(@"open_in_apple_dictionary"), @"⌘+⇧+D"]; appleDictButton.contentTintColor = NSColor.clearColor; [appleDictButton mas_remakeConstraints:^(MASConstraintMaker *make) { @@ -195,7 +195,7 @@ - (void)updateConstraints { eudicButton.link = EZEudicAppURLScheme; eudicButton.image = [[NSImage imageNamed:@"Eudic"] resizeToSize:imageSize]; - eudicButton.toolTip = [NSString stringWithFormat:@"%@, %@", NSLocalizedString(@"open_in_eudic", nil), @"⌘+⇧+⏎"]; + eudicButton.toolTip = [NSString stringWithFormat:@"%@, %@", EZLocalizedString(@"open_in_eudic"), @"⌘+⇧+⏎"]; eudicButton.contentTintColor = NSColor.clearColor; [eudicButton mas_remakeConstraints:^(MASConstraintMaker *make) { @@ -280,7 +280,7 @@ - (void)setPin:(BOOL)pin { EZBaseQueryWindow *window = (EZBaseQueryWindow *)self.window; window.pin = pin; NSString *shortcut = @"⌘+P"; - NSString *action = pin ? NSLocalizedString(@"unpin", nil) : NSLocalizedString(@"pin", nil); + NSString *action = pin ? EZLocalizedString(@"unpin") : EZLocalizedString(@"pin"); self.pinButton.toolTip = [NSString stringWithFormat:@"%@, %@", action, shortcut]; [self updatePinButtonImage]; diff --git a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m index 2f89e56d5..9ef4d391f 100644 --- a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m +++ b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m @@ -139,7 +139,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { } else if (!result.wordResult && errorDescription.length) { text = errorDescription; } else if (!result.hasTranslatedResult) { - text = NSLocalizedString(@"no_results_found", nil); + text = EZLocalizedString(@"no_results_found"); } if (text) { @@ -201,7 +201,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { if (result.promptURL.length) { NSTextField *promptTextField = [[NSTextField new] mm_put:^(NSTextField *_Nonnull textField) { [self addSubview:textField]; - textField.stringValue = NSLocalizedString(@"please_look", nil); + textField.stringValue = EZLocalizedString(@"please_look"); textField.font = [NSFont systemFontOfSize:14 * self.fontSizeRatio]; textField.editable = NO; textField.bordered = NO; @@ -565,17 +565,17 @@ - (void)refreshWithResult:(EZQueryResult *)result { // 同义词 if (result.wordResult.synonyms.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"synonyms", nil) parts:result.wordResult.synonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:EZLocalizedString(@"synonyms") parts:result.wordResult.synonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; } // 反义词 if (result.wordResult.antonyms.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"antonyms", nil) parts:result.wordResult.antonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:EZLocalizedString(@"antonyms") parts:result.wordResult.antonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; } // 搭配 if (result.wordResult.collocation.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"collocation", nil) parts:result.wordResult.collocation textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:EZLocalizedString(@"collocation") parts:result.wordResult.collocation textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; } __block NSString *lastSimpleWordPart = nil; @@ -708,7 +708,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { [self addSubview:etymologyLabel]; etymologyLabel.font = typeTextFont; etymologyLabel.textForegroundColor = typeTextColor; - etymologyLabel.text = NSLocalizedString(@"etymology", nil); + etymologyLabel.text = EZLocalizedString(@"etymology"); [etymologyLabel mas_makeConstraints:^(MASConstraintMaker *make) { if (lastView) { @@ -772,7 +772,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { audioButton.audioPlayer = self.result.service.audioPlayer; [audioButton setPlayStatus:^(BOOL isPlaying, EZAudioButton *audioButton) { - NSString *action = isPlaying ? NSLocalizedString(@"stop_play_audio", nil) : NSLocalizedString(@"play_audio", nil); + NSString *action = isPlaying ? EZLocalizedString(@"stop_play_audio") : EZLocalizedString(@"play_audio"); audioButton.toolTip = [NSString stringWithFormat:@"%@", action]; }]; @@ -841,9 +841,9 @@ - (void)refreshWithResult:(EZQueryResult *)result { NSImage *linkImage = [NSImage ez_imageWithSymbolName:@"link"]; linkButton.image = linkImage; - NSString *toolTip = NSLocalizedString(@"open_web_link", nil); + NSString *toolTip = EZLocalizedString(@"open_web_link"); if (result.serviceType == EZServiceTypeAppleDictionary) { - toolTip = NSLocalizedString(@"open_in_apple_dictionary", nil); + toolTip = EZLocalizedString(@"open_in_apple_dictionary"); } linkButton.toolTip = toolTip; diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index 11181a029..8a25e911f 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -192,6 +192,8 @@ - (void)setupUI { [self updateAllResultCellHeight]; }]; }]; + + [defaultCenter addObserver:self selector:@selector(languagePreferenceChanged:) name:EZI18nHelper.languagePreferenceChangedNotification object:nil]; } @@ -280,6 +282,10 @@ - (void)boundsDidChangeNotification:(NSNotification *)notification { [self updateAllResultCellHeight]; } +- (void)languagePreferenceChanged:(NSNotification *)notification { + [self.tableView reloadData]; +} + #pragma mark - Getter && Setter - (NSScrollView *)scrollView { @@ -1217,7 +1223,8 @@ - (EZQueryView *)createQueryView { } // placeholder, just for new user. - NSString *placeholderText = NSLocalizedString(@"placeholder", nil); + + NSString *placeholderText = EZLocalizedString(@"placeholder"); if (EZLocalStorage.shared.queryCount > 100) { placeholderText = @""; } diff --git a/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.h b/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.h index 77ee2d2df..1df73a727 100644 --- a/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.h +++ b/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.h @@ -22,11 +22,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) EZFixedQueryWindow *fixedWindow; @property (nonatomic, strong, nullable) EZMiniQueryWindow *miniWindow; -@property (nonatomic, strong) NSMutableArray *floatingWindowTypeArray; @property (nonatomic, assign) EZWindowType floatingWindowType; -@property (nonatomic, strong, nullable) EZBaseQueryWindow *floatingWindow; - -@property (nonatomic, strong) EZBaseQueryViewController *backgroundQueryViewController; +@property (nonatomic, strong, nullable, readonly) EZBaseQueryWindow *floatingWindow; /// Right-bottom offset: (15, -12) @property (nonatomic, assign) CGPoint offsetPoint; diff --git a/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.m b/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.m index f8242e51d..703f1fd13 100644 --- a/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.m +++ b/Easydict/Feature/ViewController/Window/WindowManager/EZWindowManager.m @@ -18,7 +18,8 @@ #import "Easydict-Swift.h" @interface EZWindowManager () - +@property (nonatomic, strong) NSMutableArray *floatingWindowTypeArray; +@property (nonatomic, strong) EZBaseQueryViewController *backgroundQueryViewController; @property (nonatomic, strong) NSRunningApplication *lastFrontmostApplication; @property (nonatomic, strong) EZEventMonitor *eventMonitor; @@ -32,6 +33,8 @@ @interface EZWindowManager () @property (nonatomic, copy) EZActionType actionType; +@property (nonatomic, assign) BOOL shouldCloseSettingsWhenShowingFloatingWindow; + @end @@ -70,6 +73,7 @@ - (void)setup { self.screen = NSScreen.mainScreen; self.floatingWindowTypeArray = [NSMutableArray arrayWithArray:@[ @(EZWindowTypeNone) ]]; self.actionType = EZActionTypeInvokeQuery; + self.shouldCloseSettingsWhenShowingFloatingWindow = YES; self.eventMonitor = [EZEventMonitor shared]; [self setupEventMonitor]; @@ -407,7 +411,9 @@ - (void)showFloatingWindow:(EZBaseQueryWindow *)window atPoint:(CGPoint)point { return; } - [[self currentShowingSettingsWindow] close]; + if (self.shouldCloseSettingsWhenShowingFloatingWindow) { + [[self currentShowingSettingsWindow] close]; + } // get safe window position CGPoint safeLocation = [EZCoordinateUtils getFrameSafePoint:window.frame moveToPoint:point inScreen:self.screen]; diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index c4a7ca45e..1b6e92298 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -208,7 +208,7 @@ extension Defaults.Keys { // Custom OpenAI static let customOpenAINameKey = Key( EZCustomOpenAINameKey, - default: NSLocalizedString("custom_openai", comment: "") + default: "custom_openai".localized ) static let customOpenAIAPIKey = Key(EZCustomOpenAIAPIKey, default: "") static let customOpenAITranslation = Key(EZCustomOpenAITranslationKey, default: "1") diff --git a/Easydict/NewApp/EasydictApp.swift b/Easydict/NewApp/EasydictApp.swift index 55a676234..4c0e1ca1d 100644 --- a/Easydict/NewApp/EasydictApp.swift +++ b/Easydict/NewApp/EasydictApp.swift @@ -33,7 +33,7 @@ struct EasydictApp: App { var body: some Scene { if #available(macOS 13, *) { MenuBarExtra(isInserted: $hideMenuBar.toggledValue) { - MenuItemView() + MenuItemView().environmentObject(languageState) } label: { Label { Text("Easydict") @@ -62,7 +62,7 @@ struct EasydictApp: App { .windowResizability(.contentSize) Settings { - SettingView() + SettingView().environmentObject(languageState) } } } @@ -77,6 +77,8 @@ struct EasydictApp: App { private var hideMenuBar = Defaults.Key.hideMenuBarIcon.defaultValue @Default(.selectedMenuBarIcon) private var menuBarIcon + + @StateObject private var languageState = LanguageState() } // MARK: - FakeViewToOpenSettingsInSonoma diff --git a/Easydict/NewApp/Feature/LanguagePreference/EZI18nHelper.swift b/Easydict/NewApp/Feature/LanguagePreference/EZI18nHelper.swift new file mode 100644 index 000000000..eac8fe616 --- /dev/null +++ b/Easydict/NewApp/Feature/LanguagePreference/EZI18nHelper.swift @@ -0,0 +1,71 @@ +// +// EZI18nHelper.swift +// Easydict +// +// Created by choykarl on 2024/3/4. +// Copyright © 2024 izual. All rights reserved. +// + +import SwiftUI + +var localizedBundle: Bundle { + EZI18nHelper.shared.localizedBundle +} + +// MARK: - EZI18nHelper + +@objcMembers +class EZI18nHelper: NSObject { + static let languagePreferenceChangedNotification = "EZLanguagePreferenceChangedNotification" + static let shared = EZI18nHelper() + + var localizedBundle: Bundle { + let res = localizeCode + let path = Bundle.main.path(forResource: res, ofType: "lproj") + let bundle: Bundle + if let path = path { + bundle = Bundle(path: path) ?? .main + } else { + bundle = .main + } + return bundle + } + + var localizeCode: String { + UserDefaults.standard.string(forKey: kEZLanguagePreferenceLocalKey) ?? LanguageState.LanguageType + .simplifiedChinese.rawValue + } + + var languageType: LanguageState.LanguageType { + LanguageState.LanguageType(rawValue: localizeCode) ?? .simplifiedChinese + } + + var isSimplifiedChineseLocalize: Bool { + localizeCode == LanguageState.LanguageType.simplifiedChinese.rawValue + } + + class func localized(key: String) -> String { + key.localized + } +} + +extension String { + var localized: String { + NSLocalizedString(self, bundle: localizedBundle, value: "", comment: "") + } +} + +/// https://stackoverflow.com/questions/60841915/how-to-change-localizedstringkey-to-string-in-swiftui +extension LocalizedStringKey { + // This will mirror the `LocalizedStringKey` so it can access its + // internal `key` property. Mirroring is rather expensive, but it + // should be fine performance-wise, unless you are + // using it too much or doing something out of the norm. + var stringKey: String? { + Mirror(reflecting: self).children.first(where: { $0.label == "key" })?.value as? String + } + + var stringKeyLocalized: String { + (stringKey ?? "").localized + } +} diff --git a/Easydict/NewApp/Feature/LanguagePreference/LanguageState.swift b/Easydict/NewApp/Feature/LanguagePreference/LanguageState.swift new file mode 100644 index 000000000..4cc6695ec --- /dev/null +++ b/Easydict/NewApp/Feature/LanguagePreference/LanguageState.swift @@ -0,0 +1,44 @@ +// +// LanguageState.swift +// Easydict +// +// Created by choykarl on 2024/3/3. +// Copyright © 2024 izual. All rights reserved. +// + +import SwiftUI + +// MARK: - LanguageState + +let kEZLanguagePreferenceLocalKey = "kEZLanguagePreferenceLocalKey" + +// MARK: - LanguageState + +class LanguageState: ObservableObject { + enum LanguageType: String, CaseIterable { + case english = "en" + case simplifiedChinese = "zh-CN" + + // MARK: Internal + + var name: String { + switch self { + case .english: + "English" + case .simplifiedChinese: + "简体中文" + } + } + } + + @AppStorage(kEZLanguagePreferenceLocalKey) var language: LanguageType = (.init( + rawValue: Locale.current.identifier + ) ?? .simplifiedChinese) { + didSet { + NotificationCenter.default.post( + name: NSNotification.Name(rawValue: EZI18nHelper.languagePreferenceChangedNotification), + object: nil + ) + } + } +} diff --git a/Easydict/NewApp/Model/TTSServiceType.swift b/Easydict/NewApp/Model/TTSServiceType.swift index e95857bfb..9f5aeb43e 100644 --- a/Easydict/NewApp/Model/TTSServiceType.swift +++ b/Easydict/NewApp/Model/TTSServiceType.swift @@ -22,19 +22,19 @@ enum TTSServiceType: String, CaseIterable { // MARK: CustomLocalizedStringResourceConvertible @available(macOS 13, *) -extension TTSServiceType: CustomLocalizedStringResourceConvertible { - var localizedStringResource: LocalizedStringResource { +extension TTSServiceType { + var localizedString: String { switch self { case .youdao: - "setting.tts_service.options.youdao" + "setting.tts_service.options.youdao".localized case .bing: - "setting.tts_service.options.bing" + "setting.tts_service.options.bing".localized case .google: - "setting.tts_service.options.google" + "setting.tts_service.options.google".localized case .baidu: - "setting.tts_service.options.baidu" + "setting.tts_service.options.baidu".localized case .apple: - "setting.tts_service.options.apple" + "setting.tts_service.options.apple".localized } } } diff --git a/Easydict/NewApp/Utility/Extensions/LanguageDetectOptimizeExtensions.swift b/Easydict/NewApp/Utility/Extensions/LanguageDetectOptimizeExtensions.swift index 0ccf7375e..672258f11 100644 --- a/Easydict/NewApp/Utility/Extensions/LanguageDetectOptimizeExtensions.swift +++ b/Easydict/NewApp/Utility/Extensions/LanguageDetectOptimizeExtensions.swift @@ -22,17 +22,17 @@ extension LanguageDetectOptimize: CaseIterable { // MARK: - LanguageDetectOptimize + CustomLocalizedStringResourceConvertible @available(macOS 13, *) -extension LanguageDetectOptimize: CustomLocalizedStringResourceConvertible { - public var localizedStringResource: LocalizedStringResource { +extension LanguageDetectOptimize { + public var localizedStringResource: String { switch self { case .none: - "language_detect_optimize_none" + "language_detect_optimize_none".localized case .google: - "language_detect_optimize_google" + "language_detect_optimize_google".localized case .baidu: - "language_detect_optimize_baidu" + "language_detect_optimize_baidu".localized @unknown default: - "unknown_option" + "unknown_option".localized } } } diff --git a/Easydict/NewApp/Utility/Extensions/LanguageExtensions.swift b/Easydict/NewApp/Utility/Extensions/LanguageExtensions.swift index 48ab3358b..f28adea1c 100644 --- a/Easydict/NewApp/Utility/Extensions/LanguageExtensions.swift +++ b/Easydict/NewApp/Utility/Extensions/LanguageExtensions.swift @@ -55,7 +55,7 @@ extension Language { } public var localizedName: String { - if EZLanguageManager.shared().isSystemChineseFirstLanguage() { + if EZI18nHelper.shared.isSimplifiedChineseLocalize { chineseName } else { if self == .auto { diff --git a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/CustomOpenAIService+ConfigurableService.swift b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/CustomOpenAIService+ConfigurableService.swift index 1672f8bd9..b6fa6ca54 100644 --- a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/CustomOpenAIService+ConfigurableService.swift +++ b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/CustomOpenAIService+ConfigurableService.swift @@ -59,13 +59,13 @@ private struct CustomOpenAIServiceConfigurationView: View { ) // model TextField( - "service.configuration.custom_openai.supported_models.title", + "service.configuration.custom_openai.supported_models.title".localized, text: viewModel.$availableModels ?? "", - prompt: Text("service.configuration.custom_openai.model.placeholder") + prompt: Text("service.configuration.custom_openai.model.placeholder".localized) ) .padding(10.0) Picker( - "service.configuration.openai.model.title", + "service.configuration.openai.model.title".localized, selection: viewModel.$model ) { ForEach(viewModel.validModels, id: \.self) { value in diff --git a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/DeepLTranslate+ConfigurableService.swift b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/DeepLTranslate+ConfigurableService.swift index 8e5dafa43..6cb25202e 100644 --- a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/DeepLTranslate+ConfigurableService.swift +++ b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/DeepLTranslate+ConfigurableService.swift @@ -65,23 +65,11 @@ extension DeepLAPIUsagePriority: EnumLocalizedStringConvertible { var title: String { switch self { case .webFirst: - NSLocalizedString( - "service.configuration.deepl.web_first.title", - bundle: .main, - comment: "" - ) + "service.configuration.deepl.web_first.title".localized case .authKeyFirst: - NSLocalizedString( - "service.configuration.deepl.authkey_first.title", - bundle: .main, - comment: "" - ) + "service.configuration.deepl.authkey_first.title".localized case .authKeyOnly: - NSLocalizedString( - "service.configuration.deepl.authkey_only.title", - bundle: .main, - comment: "" - ) + "service.configuration.deepl.authkey_only.title".localized } } } diff --git a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift index 739e9d2c8..fc13e2a3c 100644 --- a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift +++ b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift @@ -168,23 +168,11 @@ extension OpenAIUsageStats: EnumLocalizedStringConvertible { var title: String { switch self { case .default: - NSLocalizedString( - "service.configuration.openai.usage_status_default.title", - bundle: .main, - comment: "" - ) + "service.configuration.openai.usage_status_default.title".localized case .alwaysOff: - NSLocalizedString( - "service.configuration.openai.usage_status_always_off.title", - bundle: .main, - comment: "" - ) + "service.configuration.openai.usage_status_always_off.title".localized case .alwaysOn: - NSLocalizedString( - "service.configuration.openai.usage_status_always_on.title", - bundle: .main, - comment: "" - ) + "service.configuration.openai.usage_status_always_on.title".localized } } } diff --git a/Easydict/NewApp/Utility/Extensions/ShowWindowPositionExtensions.swift b/Easydict/NewApp/Utility/Extensions/ShowWindowPositionExtensions.swift index 1634bba6a..fe23b13a3 100644 --- a/Easydict/NewApp/Utility/Extensions/ShowWindowPositionExtensions.swift +++ b/Easydict/NewApp/Utility/Extensions/ShowWindowPositionExtensions.swift @@ -22,19 +22,19 @@ extension EZShowWindowPosition: CaseIterable { // MARK: - EZShowWindowPosition + CustomLocalizedStringResourceConvertible @available(macOS 13, *) -extension EZShowWindowPosition: CustomLocalizedStringResourceConvertible { - public var localizedStringResource: LocalizedStringResource { +extension EZShowWindowPosition { + public var localizedStringResource: String { switch self { case .right: - "fixed_window_position_right" + "fixed_window_position_right".localized case .mouse: - "fixed_window_position_mouse" + "fixed_window_position_mouse".localized case .former: - "fixed_window_position_former" + "fixed_window_position_former".localized case .center: - "fixed_window_position_center" + "fixed_window_position_center".localized @unknown default: - "unknown_option" + "unknown_option".localized } } } diff --git a/Easydict/NewApp/Utility/Extensions/WindowTypeExtensions.swift b/Easydict/NewApp/Utility/Extensions/WindowTypeExtensions.swift index c6d02f294..995b86395 100644 --- a/Easydict/NewApp/Utility/Extensions/WindowTypeExtensions.swift +++ b/Easydict/NewApp/Utility/Extensions/WindowTypeExtensions.swift @@ -20,19 +20,19 @@ extension EZWindowType { // MARK: - EZWindowType + CustomLocalizedStringResourceConvertible @available(macOS 13, *) -extension EZWindowType: CustomLocalizedStringResourceConvertible { - public var localizedStringResource: LocalizedStringResource { +extension EZWindowType { + public var localizedStringResource: String { switch self { case .fixed: - "fixed_window" + "fixed_window".localized case .main: - "main_window" + "main_window".localized case .mini: - "mini_window" + "mini_window".localized case .none: - "none_window" + "none_window".localized @unknown default: - "unknown_option" + "unknown_option".localized } } } diff --git a/Easydict/NewApp/View/MenuItemView.swift b/Easydict/NewApp/View/MenuItemView.swift index 26798bef9..51f6b0650 100644 --- a/Easydict/NewApp/View/MenuItemView.swift +++ b/Easydict/NewApp/View/MenuItemView.swift @@ -101,7 +101,7 @@ struct MenuItemView: View { @ViewBuilder private var settingItem: some View { if #available(macOS 14.0, *) { SettingsLink { - Text("Settings...") + Text("Settings...".localized) } preAction: { NSLog("打开设置") NSApp.activate(ignoringOtherApps: true) @@ -109,7 +109,7 @@ struct MenuItemView: View { // nothing to do } } else { - Button("Settings...") { + Button("Settings...".localized) { NSLog("打开设置") NSApp.activate(ignoringOtherApps: true) NSApplication.shared.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) @@ -126,7 +126,7 @@ struct MenuItemView: View { } label: { HStack { Image(systemName: "keyboard") - Text("menu_input_translate") + Text("menu_input_translate".localized) } } } @@ -138,7 +138,7 @@ struct MenuItemView: View { } label: { HStack { Image(systemName: "camera.viewfinder") - Text("menu_screenshot_Translate") + Text("menu_screenshot_Translate".localized) } } } @@ -150,7 +150,7 @@ struct MenuItemView: View { } label: { HStack { Image(systemName: "highlighter") - Text("menu_selectWord_Translate") + Text("menu_selectWord_Translate".localized) } } } @@ -162,7 +162,7 @@ struct MenuItemView: View { } label: { HStack { Image(systemName: "dock.rectangle") - Text("menu_show_mini_window") + Text("menu_show_mini_window".localized) } } } @@ -174,7 +174,7 @@ struct MenuItemView: View { } label: { HStack { Image(systemName: "camera.metering.spot") - Text("menu_silent_screenshot_OCR") + Text("menu_silent_screenshot_OCR".localized) } } } @@ -182,31 +182,31 @@ struct MenuItemView: View { // MARK: - Setting @ViewBuilder private var checkUpdateItem: some View { - Button("check_updates") { + Button("check_updates".localized) { NSLog("检查更新") Configuration.shared.updater.checkForUpdates() }.disabled(!store.canCheckForUpdates) } @ViewBuilder private var quitItem: some View { - Button("quit") { + Button("quit".localized) { NSLog("退出应用") NSApplication.shared.terminate(nil) } } @ViewBuilder private var helpItem: some View { - Menu("Help") { - Button("Feedback") { + Menu("Help".localized) { + Button("Feedback".localized) { guard let versionURL = URL(string: "\(EZGithubRepoEasydictURL)/issues") else { return } openURL(versionURL) } - Button("Export Log") { + Button("Export Log".localized) { exportLogAction() } - Button("Log Directory") { + Button("Log Directory".localized) { NSLog("日志目录") let logPath = MMManagerForLog.rootLogDirectory() ?? "" let directoryURL = URL(fileURLWithPath: logPath) diff --git a/Easydict/NewApp/View/SettingView/SettingView.swift b/Easydict/NewApp/View/SettingView/SettingView.swift index c5033557c..db60517ab 100644 --- a/Easydict/NewApp/View/SettingView/SettingView.swift +++ b/Easydict/NewApp/View/SettingView/SettingView.swift @@ -29,30 +29,30 @@ struct SettingView: View { var body: some View { TabView(selection: $selection) { GeneralTab() - .tabItem { Label("setting_general", systemImage: "gear") } + .tabItem { Label("setting_general".localized, systemImage: "gear") } .tag(SettingTab.general) ServiceTab() - .tabItem { Label("service", systemImage: "briefcase") } + .tabItem { Label("service".localized, systemImage: "briefcase") } .tag(SettingTab.service) DisabledAppTab() - .tabItem { Label("disabled_app_list", systemImage: "nosign") } + .tabItem { Label("disabled_app_list".localized, systemImage: "nosign") } .tag(SettingTab.disabled) ShortcutTab() - .tabItem { Label("shortcut", systemImage: "command.square") } + .tabItem { Label("shortcut".localized, systemImage: "command.square") } .tag(SettingTab.shortcut) AdvancedTab() - .tabItem { Label("advanced", systemImage: "gearshape.2") } + .tabItem { Label("advanced".localized, systemImage: "gearshape.2") } .tag(SettingTab.advanced) PrivacyTab() - .tabItem { Label("privacy", systemImage: "hand.raised.square") } + .tabItem { Label("privacy".localized, systemImage: "hand.raised.square") } .tag(SettingTab.privacy) AboutTab() - .tabItem { Label("about", systemImage: "info.bubble") } + .tabItem { Label("about".localized, systemImage: "info.bubble") } .tag(SettingTab.about) } .background( @@ -100,6 +100,7 @@ struct SettingView: View { @State private var selection = SettingTab.general @State private var window: NSWindow? + @EnvironmentObject private var languageState: LanguageState } @available(macOS 13, *) diff --git a/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift b/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift index f761cf664..b0d042c20 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift @@ -21,11 +21,11 @@ struct AboutTab: View { .frame(width: 110, height: 110) Text(appName) .font(.system(size: 26, weight: .semibold)) - Text("current_version") + Text(verbatim: " \(version)") + Text("current_version".localized) + Text(verbatim: " \(version)") .font(.system(size: 14)) HStack { - Text("author") + Text("author".localized) Link("Tisfeng", destination: URL(string: EZGithubRepoEasydictURL)!.deletingLastPathComponent()) } HStack { @@ -42,6 +42,8 @@ struct AboutTab: View { // MARK: Private + @EnvironmentObject private var languageState: LanguageState + private var appName: String { Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "" } diff --git a/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift index b28381b93..1afab88a8 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift @@ -16,21 +16,21 @@ struct AdvancedTab: View { var body: some View { Form { Section { - Picker("setting.general.advance.default_tts_service", selection: $defaultTTSServiceType) { + Picker("setting.general.advance.default_tts_service".localized, selection: $defaultTTSServiceType) { ForEach(TTSServiceType.allCases, id: \.rawValue) { option in - Text(option.localizedStringResource) + Text(option.localizedString) .tag(option) } } - Toggle("setting.general.advance.enable_beta_feature", isOn: $enableBetaFeature) + Toggle("setting.general.advance.enable_beta_feature".localized, isOn: $enableBetaFeature) Toggle(isOn: $enableBetaNewApp) { - Text("enable_beta_new_app") + Text("enable_beta_new_app".localized) } Toggle(isOn: $disableTipsView) { - Text("disable_tips_view") + Text("disable_tips_view".localized) } } header: { - Text("setting.general.advance.header") + Text("setting.general.advance.header".localized) } } .formStyle(.grouped) diff --git a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift index 5545d2678..b717a07fe 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift @@ -99,7 +99,7 @@ struct DisabledAppTab: View { .alert(isPresented: $disabledAppViewModel.isShowImportErrorAlert) { Alert( title: Text(""), - message: Text("setting.disabled.import_app_error.message"), + message: Text("setting.disabled.import_app_error.message".localized), dismissButton: .default(Text("ok")) ) } @@ -137,7 +137,7 @@ struct DisabledAppTab: View { var body: some View { VStack { - Text("disabled_title") + Text("disabled_title".localized) .padding(.horizontal) .padding(.top, 18) .padding(.bottom, 8) @@ -150,6 +150,7 @@ struct DisabledAppTab: View { // MARK: Private @StateObject private var disabledAppViewModel = DisabledAppViewModel() + @EnvironmentObject private var languageState: LanguageState } // MARK: - ListToolbar diff --git a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift index 1a1554198..a202f60c6 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift @@ -42,52 +42,55 @@ struct GeneralTab: View { var body: some View { Form { Section { - Picker("setting.general.appearance.light_dark_appearance", selection: $appearanceType) { + Picker("setting.general.appearance.light_dark_appearance".localized, selection: $appearanceType) { ForEach(AppearenceType.allCases, id: \.rawValue) { option in Text(option.title) .tag(option) } } } header: { - Text("setting.general.appearance.header") + Text("setting.general.appearance.header".localized) } Section { FirstAndSecondLanguageSettingView() - Picker("setting.general.language.language_detect_optimize", selection: $languageDetectOptimize) { + Picker( + "setting.general.language.language_detect_optimize".localized, + selection: $languageDetectOptimize + ) { ForEach(LanguageDetectOptimize.allCases, id: \.rawValue) { option in Text(option.localizedStringResource) .tag(option) } } } header: { - Text("setting.general.language.header") + Text("setting.general.language.header".localized) } Section { - Toggle("auto_show_query_icon", isOn: $autoSelectText) - Toggle("force_auto_get_selected_text", isOn: $forceAutoGetSelectedText) - Toggle("click_icon_query_info", isOn: $clickQuery) + Toggle("auto_show_query_icon".localized, isOn: $autoSelectText) + Toggle("force_auto_get_selected_text".localized, isOn: $forceAutoGetSelectedText) + Toggle("click_icon_query_info".localized, isOn: $clickQuery) Toggle( - "setting.general.mouse_query.adjust_pop_button_origin", + "setting.general.mouse_query.adjust_pop_button_origin".localized, isOn: $adjustPopButtonOrigin ) // 调整查询图标位置: } header: { - Text("setting.general.mouse_query.header") + Text("setting.general.mouse_query.header".localized) } Section { Toggle( - "setting.general.voice.disable_empty_copy_beep_msg", + "setting.general.voice.disable_empty_copy_beep_msg".localized, isOn: $disableEmptyCopyBeep ) // 禁用提示音:划词内容为空时生效 - Toggle("setting.general.voice.auto_play_word_audio", isOn: $autoPlayAudio) // 查询英语单词后自动播放发音 + Toggle("setting.general.voice.auto_play_word_audio".localized, isOn: $autoPlayAudio) // 查询英语单词后自动播放发音 } header: { - Text("setting.general.voice.header") + Text("setting.general.voice.header".localized) } Section { Picker( - "setting.general.window.mouse_select_translate_window_type", + "setting.general.window.mouse_select_translate_window_type".localized, selection: $mouseSelectTranslateWindowType ) { ForEach(EZWindowType.availableOptions, id: \.rawValue) { option in @@ -96,7 +99,7 @@ struct GeneralTab: View { } } Picker( - "setting.general.window.shortcut_select_translate_window_type", + "setting.general.window.shortcut_select_translate_window_type".localized, selection: $shortcutSelectTranslateWindowType ) { ForEach(EZWindowType.availableOptions, id: \.rawValue) { option in @@ -104,49 +107,52 @@ struct GeneralTab: View { .tag(option) } } - Picker("setting.general.window.fixed_window_position", selection: $fixedWindowPosition) { + Picker("setting.general.window.fixed_window_position".localized, selection: $fixedWindowPosition) { ForEach(EZShowWindowPosition.allCases, id: \.rawValue) { option in Text(option.localizedStringResource) .tag(option) } } } header: { - Text("setting.general.windows.header") + Text("setting.general.windows.header".localized) } Section { - Toggle("clear_input_when_translating", isOn: $clearInput) - Toggle("keep_prev_result_when_selected_text_is_empty", isOn: $keepPrevResultWhenEmpty) - Toggle("select_query_text_when_window_activate", isOn: $selectQueryTextWhenWindowActivate) - Toggle("automatically_remove_code_comment_symbols", isOn: $automaticallyRemoveCodeCommentSymbols) - Toggle("automatic_word_segmentation", isOn: $automaticWordSegmentation) + Toggle("clear_input_when_translating".localized, isOn: $clearInput) + Toggle("keep_prev_result_when_selected_text_is_empty".localized, isOn: $keepPrevResultWhenEmpty) + Toggle("select_query_text_when_window_activate".localized, isOn: $selectQueryTextWhenWindowActivate) + Toggle( + "automatically_remove_code_comment_symbols".localized, + isOn: $automaticallyRemoveCodeCommentSymbols + ) + Toggle("automatic_word_segmentation".localized, isOn: $automaticWordSegmentation) } header: { - Text("setting.general.input.header") + Text("setting.general.input.header".localized) } Section { - Toggle("auto_query_ocr_text", isOn: $autoQueryOCRText) - Toggle("auto_query_selected_text", isOn: $autoQuerySelectedText) - Toggle("auto_query_pasted_text", isOn: $autoQueryPastedText) + Toggle("auto_query_ocr_text".localized, isOn: $autoQueryOCRText) + Toggle("auto_query_selected_text".localized, isOn: $autoQuerySelectedText) + Toggle("auto_query_pasted_text".localized, isOn: $autoQueryPastedText) } header: { - Text("setting.general.auto_query.header") + Text("setting.general.auto_query.header".localized) } Section { - Toggle("auto_copy_ocr_text", isOn: $autoCopyOCRText) - Toggle("auto_copy_selected_text", isOn: $autoCopySelectedText) - Toggle("auto_copy_first_translated_text", isOn: $autoCopyFirstTranslatedText) + Toggle("auto_copy_ocr_text".localized, isOn: $autoCopyOCRText) + Toggle("auto_copy_selected_text".localized, isOn: $autoCopySelectedText) + Toggle("auto_copy_first_translated_text".localized, isOn: $autoCopyFirstTranslatedText) } header: { - Text("setting.general.auto_copy.header") + Text("setting.general.auto_copy.header".localized) } Section { - Toggle("show_google_quick_link", isOn: $showGoogleQuickLink) - Toggle("show_eudic_quick_link", isOn: $showEudicQuickLink) - Toggle("show_apple_dictionary_quick_link", isOn: $showAppleDictionaryQuickLink) - Toggle("show_setting_quick_link", isOn: $showSettingQuickLink) + Toggle("show_google_quick_link".localized, isOn: $showGoogleQuickLink) + Toggle("show_eudic_quick_link".localized, isOn: $showEudicQuickLink) + Toggle("show_apple_dictionary_quick_link".localized, isOn: $showAppleDictionaryQuickLink) + Toggle("show_setting_quick_link".localized, isOn: $showSettingQuickLink) } header: { - Text("setting.general.quick_link.header") + Text("setting.general.quick_link.header".localized) } Section { @@ -156,38 +162,38 @@ struct GeneralTab: View { fontSizeOptionIndex = UInt(newValue) }) Slider(value: bindingFontSize, in: 0.0 ... 4.0, step: 1) { - Text("setting.general.font.font_size.label") + Text("setting.general.font.font_size.label".localized) } minimumValueLabel: { - Text("small") + Text("small".localized) .font(.system(size: 10)) } maximumValueLabel: { - Text("large") + Text("large".localized) .font(.system(size: 14)) } } header: { - Text("setting.general.font.header") + Text("setting.general.font.header".localized) } footer: { - Text("hints_keyboard_shortcuts_font_size") + Text("hints_keyboard_shortcuts_font_size".localized) .font(.footnote) } Section { LabeledContent { - Button("check_now") { + Button("check_now".localized) { Configuration.shared.updater.checkForUpdates() } } label: { - Text("check_for_updates") - Text("lastest_version \(lastestVersion ?? version)") + Text("check_for_updates".localized) + Text(String(localized: "lastest_version \(lastestVersion ?? version)", bundle: localizedBundle)) } Toggle(isOn: $checkUpdaterViewModel.autoChecksForUpdates) { - Text("auto_check_update ") + Text("auto_check_update ".localized) } Toggle(isOn: $launchAtStartup) { - Text("launch_at_startup") + Text("launch_at_startup".localized) } Toggle(isOn: $hideMainWindow) { - Text("hide_main_window") + Text("hide_main_window".localized) } Toggle(isOn: $hideMenuBarIcon.didSet(execute: { state in if state { @@ -200,10 +206,10 @@ struct GeneralTab: View { } } })) { - Text("hide_menu_bar_icon") + Text("hide_menu_bar_icon".localized) } Picker( - "modify_menubar_icon", + "modify_menubar_icon".localized, selection: $selectedMenuBarIcon ) { ForEach(MenuBarIconType.allCases) { option in @@ -212,8 +218,14 @@ struct GeneralTab: View { .foregroundStyle(.primary) } } + Picker("language_preference".localized, selection: $languageState.language) { + ForEach(LanguageState.LanguageType.allCases, id: \.rawValue) { language in + Text(language.name) + .tag(language) + } + } } header: { - Text("setting.general.other.header") + Text("setting.general.app_setting.header".localized) } } .formStyle(.grouped) @@ -223,29 +235,31 @@ struct GeneralTab: View { lastestVersion = version } } - .alert("hide_menu_bar_icon", isPresented: $showRefuseAlert) { - Button("ok") { + .alert("hide_menu_bar_icon".localized, isPresented: $showRefuseAlert) { + Button("ok".localized) { showRefuseAlert = false } } message: { - Text("refuse_hide_menu_bar_icon_msg") + Text("refuse_hide_menu_bar_icon_msg".localized) } - .alert("hide_menu_bar_icon", isPresented: $showHideMenuBarIconAlert) { + .alert("hide_menu_bar_icon".localized, isPresented: $showHideMenuBarIconAlert) { HStack { - Button("ok") { + Button("ok".localized) { showHideMenuBarIconAlert = false } - Button("cancel") { + Button("cancel".localized) { Defaults[.hideMenuBarIcon] = false } } } message: { - Text("hide_menu_bar_icon_msg") + Text("hide_menu_bar_icon_msg".localized) } } // MARK: Private + @EnvironmentObject private var languageState: LanguageState + @Default(.autoSelectText) private var autoSelectText @Default(.forceAutoGetSelectedText) private var forceAutoGetSelectedText @Default(.clickQuery) private var clickQuery @@ -319,13 +333,13 @@ private struct FirstAndSecondLanguageSettingView: View { var body: some View { Group { - Picker("setting.general.language.first_language", selection: $firstLanguage) { + Picker("setting.general.language.first_language".localized, selection: $firstLanguage) { ForEach(Language.allAvailableOptions, id: \.rawValue) { option in Text(verbatim: "\(option.flagEmoji) \(option.localizedName)") .tag(option) } } - Picker("setting.general.language.second_language", selection: $secondLanguage) { + Picker("setting.general.language.second_language".localized, selection: $secondLanguage) { ForEach(Language.allAvailableOptions, id: \.rawValue) { option in Text(verbatim: "\(option.flagEmoji) \(option.localizedName)") .tag(option) @@ -347,7 +361,7 @@ private struct FirstAndSecondLanguageSettingView: View { } } .alert( - "setting.general.language.duplicated_alert.title", + "setting.general.language.duplicated_alert.title".localized, isPresented: showLanguageDuplicatedAlert, presenting: languageDuplicatedAlert ) { _ in @@ -360,18 +374,18 @@ private struct FirstAndSecondLanguageSettingView: View { // MARK: Private private struct LanguageDuplicateAlert: CustomStringConvertible { - enum Field: CustomLocalizedStringResourceConvertible { + enum Field { case first case second // MARK: Internal - var localizedStringResource: LocalizedStringResource { + var localizedString: String { switch self { case .first: - "setting.general.language.duplicated_alert.field.first" + "setting.general.language.duplicated_alert.field.first".localized case .second: - "setting.general.language.duplicated_alert.field.second" + "setting.general.language.duplicated_alert.field.second".localized } } } @@ -387,7 +401,8 @@ private struct FirstAndSecondLanguageSettingView: View { // \(setField) is replaced with \(setLanguage). String( // swiftlint:disable:next line_length - localized: "setting.general.language.duplicated_alert \(duplicatedLanguage.localizedName)\(String(localized: setField.localizedStringResource))\(setLanguage.localizedName)" + localized: "setting.general.language.duplicated_alert \(duplicatedLanguage.localizedName)\(setField.localizedString)\(setLanguage.localizedName)", + bundle: localizedBundle ) } } diff --git a/Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift b/Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift index 74d1be5f2..0aaa530f4 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift @@ -16,20 +16,20 @@ struct PrivacyTab: View { var body: some View { Form { Section { - Text("privacy_statement_content") + Text("privacy_statement_content".localized) .font(.body) .multilineTextAlignment(.leading) } header: { - Text("privacy_statement") + Text("privacy_statement".localized) } Section { HStack { - Text("crash_log") - Toggle("allow_collect_crash_log", isOn: $allowCollectCrashLog) + Text("crash_log".localized) + Toggle("allow_collect_crash_log".localized, isOn: $allowCollectCrashLog) } HStack { - Text("analytics") - Toggle("allow_collect_analytics", isOn: $allowCollectAnalytics) + Text("analytics".localized) + Toggle("allow_collect_analytics".localized, isOn: $allowCollectAnalytics) } } } diff --git a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/SecureTextField.swift b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/SecureTextField.swift index a19a684cc..b8a1bdf34 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/SecureTextField.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/SecureTextField.swift @@ -22,11 +22,11 @@ struct SecureTextField: View { var body: some View { HStack { ZStack { - SecureField(title, text: $text ?? "") + SecureField(title.stringKeyLocalized, text: $text ?? "") .lineLimit(lineLimit) .focused($focus, equals: .secure) .opacity(showText ? 0 : 1) - TextField(title, text: $text ?? "", prompt: Text(placeholder)) + TextField(title.stringKeyLocalized, text: $text ?? "", prompt: Text(placeholder.stringKeyLocalized)) .lineLimit(lineLimit) .focused($focus, equals: .text) .opacity(showText || (text?.isEmpty ?? true) ? 1 : 0) diff --git a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift index 387ebd638..a2b746246 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift @@ -55,8 +55,12 @@ struct ServiceConfigurationInputCell: View { let placeholder: LocalizedStringKey var body: some View { - TextField(textFieldTitleKey, text: $value ?? "", prompt: Text(placeholder)) - .padding(10.0) + TextField( + textFieldTitleKey.stringKeyLocalized, + text: $value ?? "", + prompt: Text(placeholder.stringKeyLocalized) + ) + .padding(10.0) } } @@ -79,7 +83,7 @@ struct ServiceConfigurationPickerCell some View { content .alert( - String(localized: "shortcut_confict \(confictAlterMessage.title)"), + String(localized: "shortcut_confict \(confictAlterMessage.title)", bundle: localizedBundle), isPresented: $showAlter, presenting: confictAlterMessage ) { _ in - Button(String(localized: "shortcut_confict_confirm")) { + Button(String(localized: "shortcut_confict_confirm", bundle: localizedBundle)) { confictAlterMessage = ShortcutConfictAlertMessage(title: "", message: "") } } message: { message in diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderRowView.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderRowView.swift index d54e577cf..3f93b06c3 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderRowView.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderRowView.swift @@ -20,7 +20,7 @@ struct KeyHolderRowView: View { var body: some View { HStack { - Text(LocalizedStringKey(title)) + Text(title.localized) Spacer() KeyHolderWrapper(shortcutType: type, confictAlterMessage: $confictAlterMessage).frame( width: 180, diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderWrapper.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderWrapper.swift index b50b31c76..a76d55b77 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderWrapper.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/KeyHolderWrapper.swift @@ -97,10 +97,14 @@ extension KeyHolderWrapper { if Shortcut.validateShortcut(key) { let title = String( - localized: "shortcut_confict_title \(key.keyEquivalentModifierMaskString + key.characters)" + localized: "shortcut_confict_title \(key.keyEquivalentModifierMaskString + key.characters)", + bundle: localizedBundle ) let message = - String(localized: "shortcut_confict_message \(Shortcut.shared.confictMenuItem?.title ?? "")") + String( + localized: "shortcut_confict_message \(Shortcut.shared.confictMenuItem?.title ?? "")", + bundle: localizedBundle + ) confictAlterMessage = ShortcutConfictAlertMessage( title: title, message: message