diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Messages.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Messages.properties new file mode 100644 index 0000000..1a2d367 --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Messages.properties @@ -0,0 +1,51 @@ +select=Select +desktop=desktop +private_collection=private collection +collections=public collection +wallpaper=wallpaper +click_to_search=Click to search +click_to_view=Click to view +source_link=Source link +copy_to_clipboard=Copy to clipboard +copy=Copy +failed_to_download_file=Failed to download file +downloading=Downloading\u2026 +failed_to_copy_files=Failed to copy files +download_completed=Download completed +download_to=Download to\u2026 +download_to_format=Download to {0} +close_this_page=Close this page +id_doesnot_exists=Searchable id does not exist! +retrieving=Retrieving\u2026 +cancel=Cancel +retrieval_format=Retrieval: {0} +failed_to_delete=Delete failed! +successfully_deleted=Deleted successfully! +id_format_is_incorrect=Input format id is incorrect +enter_id=Enter id to open +unable_to_read_version_stamp=Unable to read version stamp +enter_page_number=Enter page number +enter_search_tags=Enter search tags, separated by spaces +version=Version +help=Help +clear_cache=Clear cache +settings=Settings +exit=Exit +switch_site=Switch site +search_history=Search history +search_by_tag=Search by tag +jump_to_page=Jump to page +open_post_by_id=Open post by id +functions=Functions +reload=Reload +no_more_items=No more items +unable_to_load=Unable to load! +loading=Loading\u2026 +page_is=[page: +load_more=Load more +preview=Preview +artwork=Artwork +source=Source +parent_post=Parent post +child_post=Child post +tags=Tags diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Messages_ru_RU.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Messages_ru_RU.properties new file mode 100644 index 0000000..900e2ea --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Messages_ru_RU.properties @@ -0,0 +1,51 @@ +select=\u0412\u044b\u0431\u0440\u0430\u0442\u044c +desktop=\u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u0442\u043e\u043b +private_collection=\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f +collections=\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f +wallpaper=\u043e\u0431\u043e\u0438 +click_to_search=\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 +click_to_view=\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 +source_link=\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a +copy_to_clipboard=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430 +copy=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +failed_to_download_file=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b +downloading=\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u2026 +failed_to_copy_files=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b +download_completed=\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e +download_to=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u2026 +download_to_format=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 {0} +close_this_page=\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 +id_doesnot_exists=\u0418\u0441\u043a\u043e\u043c\u044b\u0439 id \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d +retrieving=\u041f\u043e\u0438\u0441\u043a\u2026 +cancel=\u041e\u0442\u043c\u0435\u043d\u0430 +retrieval_format=\u041e\u0442\u043a\u0440\u044b\u0442\u044c: {0} +failed_to_delete=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c! +successfully_deleted=\u0423\u0434\u0430\u043b\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e! +id_format_is_incorrect=\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 id +enter_id=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 id +unable_to_read_version_stamp=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0435\u0440\u0441\u0438\u0438 +enter_page_number=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b +enter_search_tags=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u0433\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e +version=\u0412\u0435\u0440\u0441\u0438\u044f +help=\u041f\u043e\u0438\u0441\u043a +clear_cache=\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u044d\u0448 +settings=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 +exit=\u0412\u044b\u0445\u043e\u0434 +switch_site=\u0421\u0430\u0439\u0442 +search_history=\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 +search_by_tag=\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0442\u0435\u0433\u0443 +jump_to_page=\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 +open_post_by_id=\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0441\u0442 \u043f\u043e id +functions=\u0424\u0443\u043d\u043a\u0446\u0438\u0438 +reload=\u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c +no_more_items=\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 +unable_to_load=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c! +loading=\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u2026 +page_is=[\u0441\u0442\u0440: +load_more=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0449\u0451 +preview=\u041c\u0438\u043d\u0438\u0430\u0442\u044e\u0440\u0430 +artwork=\u0410\u0440\u0442 +source=\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a +parent_post=\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 +child_post=\u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u043e\u0441\u0442 +tags=\u0422\u0435\u0433\u0438 diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Messages_zh_CN.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Messages_zh_CN.properties new file mode 100644 index 0000000..ae84ddd --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Messages_zh_CN.properties @@ -0,0 +1,51 @@ +select=\u9009\u62e9 +desktop=\u684c\u9762 +private_collection=\u975e\u516c\u5f00\u6536\u85cf +collections=\u53ef\u516c\u5f00\u6536\u85cf +wallpaper=\u58c1\u7eb8 +click_to_search=\u70b9\u51fb\u641c\u7d22 +click_to_view=\u70b9\u51fb\u67e5\u770b +source_link=\u6765\u6e90\u94fe\u63a5 +copy_to_clipboard=\u590d\u5236\u5230\u526a\u8d34\u677f +copy=\u590d\u5236 +failed_to_download_file=\u4e0b\u8f7d\u6587\u4ef6\u5931\u8d25 +downloading=\u4e0b\u8f7d\u4e2d\u2026 +failed_to_copy_files=\u590d\u5236\u6587\u4ef6\u5931\u8d25 +download_completed=\u4e0b\u8f7d\u5b8c\u6210 +download_to=\u4e0b\u8f7d\u81f3\u2026 +download_to_format=\u4e0b\u8f7d\u81f3{0} +close_this_page=\u5173\u95ed\u6b64\u6295\u7a3f\u9875 +id_doesnot_exists=\u68c0\u7d22\u7684id\u4e0d\u5b58\u5728\uff01 +retrieving=\u6b63\u5728\u68c0\u7d22\u2026 +cancel=\u53d6\u6d88 +retrieval_format=\u68c0\u7d22\u4e2d\uff1a{0} +failed_to_delete=\u5220\u9664\u5931\u8d25\uff01 +successfully_deleted=\u5220\u9664\u6210\u529f\uff01 +id_format_is_incorrect=\u8f93\u5165\u7684id\u683c\u5f0f\u6709\u8bef +enter_id=\u8f93\u5165\u8981\u68c0\u7d22\u7684id +unable_to_read_version_stamp=\u65e0\u6cd5\u8bfb\u53d6\u7248\u672c\u6807\u8bb0 +enter_page_number=\u8f93\u5165\u8981\u8df3\u8f6c\u5230\u7684\u9875\u6570 +enter_search_tags=\u8f93\u5165\u8981\u641c\u7d22\u7684tag\uff0c\u7528\u7a7a\u683c\u5206\u9694 +version=\u7248\u672c +help=\u5e2e\u52a9 +clear_cache=\u6e05\u7a7a\u7f13\u5b58 +settings=\u8bbe\u7f6e +exit=\u9000\u51fa +switch_site=\u5207\u6362\u7ad9\u70b9 +search_history=\u641c\u7d22\u5386\u53f2 +search_by_tag=\u641c\u7d22tag +jump_to_page=\u8df3\u81f3\u9875\u6570 +open_post_by_id=\u6309id\u68c0\u7d22Post +functions=\u529f\u80fd +reload=\u91cd\u65b0\u52a0\u8f7d +no_more_items=\u6ca1\u6709\u66f4\u591a\u4e86 +unable_to_load=\u52a0\u8f7d\u5931\u8d25\uff01 +loading=\u52a0\u8f7d\u4e2d\u2026 +page_is=[page: +load_more=\u52a0\u8f7d\u66f4\u591a +preview=\u9884\u89c8\u56fe +artwork=\u539f\u56fe +source=\u6765\u6e90 +parent_post=\u7236\u6295\u7a3f +child_post=\u5b50\u6295\u7a3f +tags=\u6807\u7b7e diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Settings.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Settings.properties new file mode 100644 index 0000000..eccb321 --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Settings.properties @@ -0,0 +1,22 @@ +select=Select +images_save_location=Images save location +confirm=Confirm +cancel=Cancel +upper_limit_100=Upper limit is 100 +category_1=Category 1 +category_2=Category 2 +category_3=Category 3 +category_4=Category 4 +wallpaper=Wallpaper +public_collection=Public collection +private_collection=Private collection +path=Path +name=Name +recycler=Recycler +settings=Settings +items_per_page=Items per page +miscellaneous=Miscellaneous +safe_mode=Safe mode +look_and_feel=Look and feel +restart_required=Restart required +safe_mode_tooltip=Show only suitable for browsing in public or working time images diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Settings_ru_RU.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Settings_ru_RU.properties new file mode 100644 index 0000000..08007a8 --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Settings_ru_RU.properties @@ -0,0 +1,22 @@ +select=\u0412\u044b\u0431\u0440\u0430\u0442\u044c +images_save_location=\u041f\u0430\u043f\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a +confirm=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c +cancel=\u041e\u0442\u043c\u0435\u043d\u0430 +upper_limit_100=\u041c\u0430\u043a\u0441. 100 +category_1=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f 1 +category_2=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f 2 +category_3=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f 3 +category_4=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f 4 +wallpaper=\u041e\u0431\u043e\u0438 +public_collection=\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f +private_collection=\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f +path=\u041f\u0443\u0442\u044c +name=\u0418\u043c\u044f +recycler=\u041a\u043e\u0440\u0437\u0438\u043d\u0430 +settings=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 +items_per_page=\u042d\u043b\u0435\u043c. \u043d\u0430 \u0441\u0442\u0440. +miscellaneous=\u041f\u0440\u043e\u0447\u0435\u0435 +safe_mode=\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c +look_and_feel=\u0422\u0435\u043c\u0430 +restart_required=\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a +safe_mode_tooltip=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u0438\u043b\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 diff --git a/src/main/build-resources/io/github/azige/moebooruviewer/Settings_zh_CN.properties b/src/main/build-resources/io/github/azige/moebooruviewer/Settings_zh_CN.properties new file mode 100644 index 0000000..a017248 --- /dev/null +++ b/src/main/build-resources/io/github/azige/moebooruviewer/Settings_zh_CN.properties @@ -0,0 +1,22 @@ +select=\u9009\u62e9 +images_save_location=\u56fe\u7247\u4fdd\u5b58\u4f4d\u7f6e +confirm=\u786e\u8ba4 +cancel=\u53d6\u6d88 +upper_limit_100=\u4e0a\u9650\u662f 100 +category_1=\u5206\u7c7b1 +category_2=\u5206\u7c7b2 +category_3=\u5206\u7c7b3 +category_4=\u5206\u7c7b4 +wallpaper=\u58c1\u7eb8 +public_collection=\u53ef\u516c\u5f00\u6536\u85cf +private_collection=\u975e\u516c\u5f00\u6536\u85cf +path=\u8def\u5f84 +name=\u540d\u5b57 +recycler=\u6682\u5b58 +settings=\u5206\u9875\u8bbe\u7f6e +items_per_page=\u9875\u5927\u5c0f +miscellaneous=\u6742\u9879 +safe_mode=\u5b89\u5168\u6a21\u5f0f +look_and_feel=\u5916\u89c2 +restart_required=\u9700\u8981\u91cd\u542f +safe_mode_tooltip=\u8fc7\u6ee4\u51fa\u9002\u5408\u5728\u516c\u4f17\u573a\u5408\u6216\u4e0a\u73ed\u65f6\u95f4\u6d4f\u89c8\u7684\u56fe\u7247 diff --git a/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.form b/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.form index 796f32c..23c14bf 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.form +++ b/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.form @@ -3,7 +3,9 @@
- + + + @@ -75,7 +77,9 @@ - + + + @@ -103,8 +107,12 @@ - - + + + + + + @@ -113,7 +121,9 @@ - + + + @@ -153,7 +163,9 @@ - + + + @@ -195,17 +207,23 @@ - + + + - + + + - + + + @@ -215,7 +233,9 @@ - + + + @@ -227,7 +247,9 @@ - + + + @@ -269,17 +291,23 @@ - + + + - + + + - + + + @@ -289,7 +317,9 @@ - + + + @@ -301,7 +331,9 @@ - + + + @@ -343,17 +375,23 @@ - + + + - + + + - + + + @@ -363,7 +401,9 @@ - + + + @@ -375,7 +415,9 @@ - + + + @@ -417,17 +459,23 @@ - + + + - + + + - + + + @@ -437,7 +485,9 @@ - + + + @@ -449,7 +499,9 @@ - + + + @@ -457,7 +509,9 @@ - + + + @@ -467,7 +521,9 @@ - + + + @@ -481,7 +537,7 @@ - + @@ -509,7 +565,9 @@ - + + + @@ -518,7 +576,9 @@ - + + + @@ -531,7 +591,7 @@ - + @@ -561,7 +621,9 @@ - + + + @@ -571,7 +633,9 @@ - + + + diff --git a/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.java b/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.java index fd05ac1..42c0bf4 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.java +++ b/src/main/java/io/github/azige/moebooruviewer/ConfigDialog.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; import java.util.stream.Stream; import javax.annotation.PostConstruct; @@ -35,6 +36,7 @@ public class ConfigDialog extends javax.swing.JDialog{ private Logger logger = LoggerFactory.getLogger(ConfigDialog.class); + private final ResourceBundle messages = ResourceBundle.getBundle("io/github/azige/moebooruviewer/Settings"); @Autowired private UserSetting userSetting; @@ -53,7 +55,7 @@ public ConfigDialog(){ savePaths = Arrays.asList(savePathTextField1, savePathTextField2, savePathTextField3, savePathTextField4); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - fileChooser.setApproveButtonText("选择"); + fileChooser.setApproveButtonText(messages.getString("select")); } @PostConstruct @@ -79,8 +81,7 @@ private void init(){ * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() {//GEN-BEGIN:initComponents jPanel1 = new javax.swing.JPanel(); safeModeCheckBox = new javax.swing.JCheckBox(); @@ -120,14 +121,15 @@ private void initComponents() { jLabel7 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("设置"); + setTitle(messages.getString("settings")); // NOI18N setModal(true); setResizable(false); - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("杂项")); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("io/github/azige/moebooruviewer/Settings"); // NOI18N + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("miscellaneous"))); // NOI18N - safeModeCheckBox.setText("安全模式"); - safeModeCheckBox.setToolTipText("过滤出适合在公众场合或上班时间浏览的图片"); + safeModeCheckBox.setText(messages.getString("safe_mode")); // NOI18N + safeModeCheckBox.setToolTipText(messages.getString("safe_mode_tooltip")); // NOI18N javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); @@ -146,19 +148,19 @@ private void initComponents() { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("图片保存位置")); + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("images_save_location"))); // NOI18N - jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("分类1")); + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("category_1"))); // NOI18N - jLabel1.setText("名字"); + jLabel1.setText(messages.getString("name")); // NOI18N - saveNameTextField1.setText("壁纸"); + saveNameTextField1.setText(messages.getString("wallpaper")); // NOI18N - jLabel2.setText("路径"); + jLabel2.setText(messages.getString("path")); // NOI18N savePathTextField1.setText("wallpaper"); - choosePathButton1.setText("选择"); + choosePathButton1.setText(messages.getString("select")); // NOI18N choosePathButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { choosePathButton1ActionPerformed(evt); @@ -195,17 +197,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("分类2")); + jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("category_2"))); // NOI18N - jLabel3.setText("名字"); + jLabel3.setText(messages.getString("name")); // NOI18N - saveNameTextField2.setText("可公开收藏"); + saveNameTextField2.setText(messages.getString("public_collection")); // NOI18N - jLabel4.setText("路径"); + jLabel4.setText(messages.getString("path")); // NOI18N savePathTextField2.setText("collections"); - choosePathButton2.setText("选择"); + choosePathButton2.setText(messages.getString("select")); // NOI18N choosePathButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { choosePathButton2ActionPerformed(evt); @@ -242,17 +244,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("分类4")); + jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("category_4"))); // NOI18N - jLabel9.setText("名字"); + jLabel9.setText(messages.getString("name")); // NOI18N - saveNameTextField4.setText("暂存"); + saveNameTextField4.setText(messages.getString("recycler")); // NOI18N - jLabel10.setText("路径"); + jLabel10.setText(messages.getString("path")); // NOI18N savePathTextField4.setText("recycler"); - choosePathButton4.setText("选择"); + choosePathButton4.setText(messages.getString("select")); // NOI18N choosePathButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { choosePathButton4ActionPerformed(evt); @@ -289,17 +291,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("分类3")); + jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("category_3"))); // NOI18N - jLabel11.setText("名字"); + jLabel11.setText(messages.getString("name")); // NOI18N - saveNameTextField3.setText("非公开收藏"); + saveNameTextField3.setText(messages.getString("private_collection")); // NOI18N - jLabel12.setText("路径"); + jLabel12.setText(messages.getString("path")); // NOI18N savePathTextField3.setText(".collections"); - choosePathButton3.setText("选择"); + choosePathButton3.setText(messages.getString("select")); // NOI18N choosePathButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { choosePathButton3ActionPerformed(evt); @@ -362,25 +364,25 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); - confirmButton.setText("确认"); + confirmButton.setText(messages.getString("confirm")); // NOI18N confirmButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { confirmButtonActionPerformed(evt); } }); - cancelButton.setText("取消"); + cancelButton.setText(messages.getString("cancel")); // NOI18N cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); - jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("外观")); + jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("look_and_feel"))); // NOI18N lafComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Windows" })); - jLabel5.setText("需要重启"); + jLabel5.setText(messages.getString("restart_required")); // NOI18N javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); @@ -391,7 +393,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) - .addContainerGap(36, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -403,13 +405,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("分页设置")); + jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("settings"))); // NOI18N - jLabel6.setText("页大小"); + jLabel6.setText(messages.getString("items_per_page")); // NOI18N pageSizeTextField.setText("20"); - jLabel7.setText("上限是 100"); + jLabel7.setText(messages.getString("upper_limit_100")); // NOI18N javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); @@ -420,7 +422,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jLabel6) - .addGap(18, 18, 18) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pageSizeTextField)) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jLabel7) @@ -478,7 +480,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); pack(); - }// //GEN-END:initComponents + }//GEN-END:initComponents @PreDestroy @Override diff --git a/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.form b/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.form index 43c7cb5..4d9b91e 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.form +++ b/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.form @@ -10,7 +10,9 @@ - + + + @@ -22,7 +24,9 @@ - + + + @@ -30,7 +34,9 @@ - + + + @@ -38,7 +44,9 @@ - + + + @@ -46,7 +54,9 @@ - + + + @@ -54,7 +64,9 @@ - + + + @@ -62,7 +74,9 @@ - + + + @@ -87,7 +101,9 @@ - + + + @@ -97,12 +113,16 @@ - + + + - + + + @@ -110,7 +130,9 @@ - + + + @@ -120,12 +142,16 @@ - + + + - + + + diff --git a/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.java b/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.java index f08e559..4c3eae3 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.java +++ b/src/main/java/io/github/azige/moebooruviewer/ListPostFrame.java @@ -98,7 +98,7 @@ public void layoutContainer(Container target){ }); scrollPane.getVerticalScrollBar().setUnitIncrement(20); - loadMoreLabel = new JLabel("加载更多"); + loadMoreLabel = new JLabel(Localization.getString("load_more")); loadMoreLabel.setForeground(Color.WHITE); loadMoreLabel.setHorizontalAlignment(JLabel.CENTER); loadMoreLabel.setPreferredSize(new Dimension(PREVIEW_WIDTH, PREVIEW_HEIGHT)); @@ -142,7 +142,7 @@ protected void processWindowEvent(WindowEvent e){ private void refreshTitle(){ StringBuilder sb = new StringBuilder(); sb.append(siteConfig.getName()).append(" Viewer"); - sb.append(" [page: ").append(pageCount).append("]"); + sb.append(' ').append(Localization.getString("page_is")).append(' ').append(pageCount).append("]"); if (tags.length > 0){ sb.append(" [").append(Stream.of(tags).reduce((a, b) -> a + " " + b).get()).append("]"); } @@ -151,7 +151,7 @@ private void refreshTitle(){ } public void loadImages(){ - loadMoreLabel.setText("加载中……"); + loadMoreLabel.setText(Localization.getString("loading")); loadMoreLabel.setEnabled(false); refreshTitle(); executor.execute(() -> { @@ -164,7 +164,7 @@ public void loadImages(){ continue; } posts.add(post); - JLabel label = new JLabel("加载中……"); + JLabel label = new JLabel(Localization.getString("loading")); label.setForeground(Color.WHITE); label.setHorizontalAlignment(JLabel.CENTER); label.setPreferredSize(new Dimension(PREVIEW_WIDTH, PREVIEW_HEIGHT)); @@ -188,7 +188,7 @@ public void run(){ Dimension size = label.getPreferredSize(); label.setIcon(new ImageIcon(Utils.resizeImage(image, size.getWidth(), size.getHeight()))); }else{ - label.setText("加载失败!"); + label.setText(Localization.getString("unable_to_load")); } }); } @@ -229,10 +229,10 @@ private void popupMenu(MouseEvent e){ } postsPanel.add(loadMoreLabel); if (!postList.isEmpty()){ - loadMoreLabel.setText("加载更多"); + loadMoreLabel.setText(Localization.getString("load_more")); loadMoreLabel.setEnabled(true); }else{ - loadMoreLabel.setText("没有更多了"); + loadMoreLabel.setText(Localization.getString("no_more_items")); } }); }); @@ -251,8 +251,7 @@ public void clear(){ * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() {//GEN-BEGIN:initComponents postPreviewPopupMenu = new javax.swing.JPopupMenu(); reloadMenuItem = new javax.swing.JMenuItem(); @@ -275,7 +274,8 @@ private void initComponents() { jMenu3 = new javax.swing.JMenu(); showVersionMenuItem = new javax.swing.JMenuItem(); - reloadMenuItem.setText("重新加载"); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("io/github/azige/moebooruviewer/Messages"); // NOI18N + reloadMenuItem.setText(bundle.getString("reload")); // NOI18N reloadMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { reloadMenuItemActionPerformed(evt); @@ -295,10 +295,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { postsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); scrollPane.setViewportView(postsPanel); - jMenu1.setText("功能"); + jMenu1.setText(bundle.getString("functions")); // NOI18N jMenu1.setMinimumSize(new java.awt.Dimension(200, 0)); - openPostMenuItem.setText("按id检索Post"); + openPostMenuItem.setText(bundle.getString("open_post_by_id")); // NOI18N openPostMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openPostMenuItemActionPerformed(evt); @@ -306,7 +306,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jMenu1.add(openPostMenuItem); - jumpPageMenuItem.setText("跳至页数"); + jumpPageMenuItem.setText(bundle.getString("jump_to_page")); // NOI18N jumpPageMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jumpPageMenuItemActionPerformed(evt); @@ -314,7 +314,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jMenu1.add(jumpPageMenuItem); - searchTagMenuItem.setText("搜索tag"); + searchTagMenuItem.setText(bundle.getString("search_by_tag")); // NOI18N searchTagMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchTagMenuItemActionPerformed(evt); @@ -322,7 +322,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jMenu1.add(searchTagMenuItem); - searchHistoryMenu.setText("搜索历史"); + searchHistoryMenu.setText(bundle.getString("search_history")); // NOI18N searchHistoryMenu.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { searchHistoryMenuMouseEntered(evt); @@ -330,7 +330,7 @@ public void mouseEntered(java.awt.event.MouseEvent evt) { }); jMenu1.add(searchHistoryMenu); - jMenu2.setText("切换站点"); + jMenu2.setText(bundle.getString("switch_site")); // NOI18N switchKonachanMenuItem.setText("Konachan.com"); switchKonachanMenuItem.addActionListener(new java.awt.event.ActionListener() { @@ -351,7 +351,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu1.add(jMenu2); jMenu1.add(jSeparator1); - exitMenuItem.setText("退出"); + exitMenuItem.setText(bundle.getString("exit")); // NOI18N exitMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); @@ -361,9 +361,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuBar1.add(jMenu1); - jMenu4.setText("设置"); + jMenu4.setText(bundle.getString("settings")); // NOI18N - configMenuItem.setText("设置"); + configMenuItem.setText(bundle.getString("settings")); // NOI18N configMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { configMenuItemActionPerformed(evt); @@ -371,7 +371,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jMenu4.add(configMenuItem); - cleanCacheMenuItem.setText("清空缓存"); + cleanCacheMenuItem.setText(bundle.getString("clear_cache")); // NOI18N cleanCacheMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cleanCacheMenuItemActionPerformed(evt); @@ -381,9 +381,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuBar1.add(jMenu4); - jMenu3.setText("帮助"); + jMenu3.setText(bundle.getString("help")); // NOI18N - showVersionMenuItem.setText("版本"); + showVersionMenuItem.setText(bundle.getString("version")); // NOI18N showVersionMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showVersionMenuItemActionPerformed(evt); @@ -407,10 +407,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); pack(); - }// //GEN-END:initComponents + }//GEN-END:initComponents private void searchTagMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchTagMenuItemActionPerformed - String keywords = JOptionPane.showInputDialog(this, "输入要搜索的tag,用空格分隔"); + String keywords = JOptionPane.showInputDialog(this, Localization.getString("enter_search_tags")); if (keywords != null){ moebooruViewer.listPosts(keywords.split(" ")); userSetting.addSearchHistory(keywords); @@ -430,7 +430,7 @@ private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN- }//GEN-LAST:event_exitMenuItemActionPerformed private void jumpPageMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jumpPageMenuItemActionPerformed - String pageString = JOptionPane.showInputDialog(this, "输入要跳转到的页数"); + String pageString = JOptionPane.showInputDialog(this, Localization.getString("enter_page_number")); if (pageString != null){ pageCount = Integer.parseInt(pageString); clear(); @@ -453,17 +453,17 @@ private void showVersionMenuItemActionPerformed(java.awt.event.ActionEvent evt) version = IOUtils.toString(getClass().getResourceAsStream("/io/github/azige/moebooruviewer/version")); JOptionPane.showMessageDialog(this, version); }catch (IOException ex){ - logger.error("无法读取版本标记", ex); + logger.error(Localization.getString("unable_to_read_version_stamp"), ex); } }//GEN-LAST:event_showVersionMenuItemActionPerformed private void openPostMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openPostMenuItemActionPerformed - String id = JOptionPane.showInputDialog(this, "输入要检索的id"); + String id = JOptionPane.showInputDialog(this, Localization.getString("enter_id")); if (id != null){ try{ moebooruViewer.showPostById(Integer.parseInt(id)); }catch (NumberFormatException ex){ - JOptionPane.showMessageDialog(null, "输入的id格式有误"); + JOptionPane.showMessageDialog(null, Localization.getString("id_format_is_incorrect")); } } }//GEN-LAST:event_openPostMenuItemActionPerformed @@ -476,15 +476,15 @@ private void configMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GE private void cleanCacheMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cleanCacheMenuItemActionPerformed if (netIO.cleanCache()){ - JOptionPane.showMessageDialog(this, "删除成功!"); + JOptionPane.showMessageDialog(this, Localization.getString("successfully_deleted")); }else{ - JOptionPane.showMessageDialog(this, "删除失败!"); + JOptionPane.showMessageDialog(this, Localization.getString("failed_to_delete")); } }//GEN-LAST:event_cleanCacheMenuItemActionPerformed private void reloadMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reloadMenuItemActionPerformed showingPopupMenuLabel.setIcon(null); - showingPopupMenuLabel.setText("加载中……"); + showingPopupMenuLabel.setText(Localization.getString("loading")); JLabel label = showingPopupMenuLabel; Post post = showingPopupMenuPost; @@ -496,7 +496,7 @@ private void reloadMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GE Dimension size = label.getPreferredSize(); label.setIcon(new ImageIcon(Utils.resizeImage(image, size.getWidth(), size.getHeight()))); }else{ - label.setText("加载失败!"); + label.setText(Localization.getString("unable_to_load")); } }); }); diff --git a/src/main/java/io/github/azige/moebooruviewer/Localization.java b/src/main/java/io/github/azige/moebooruviewer/Localization.java new file mode 100644 index 0000000..df57f76 --- /dev/null +++ b/src/main/java/io/github/azige/moebooruviewer/Localization.java @@ -0,0 +1,21 @@ +package io.github.azige.moebooruviewer; + +import java.text.MessageFormat; +import java.util.ResourceBundle; + +public final class Localization { + + private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("io/github/azige/moebooruviewer/Messages"); + + public static ResourceBundle getBundle() { + return BUNDLE; + } + + public static String getString(String key) { + return BUNDLE.getString(key); + } + + public static String format(String key, Object... keys) { + return MessageFormat.format(getString(key), keys); + } +} diff --git a/src/main/java/io/github/azige/moebooruviewer/MoebooruViewer.java b/src/main/java/io/github/azige/moebooruviewer/MoebooruViewer.java index 1684469..ec74df7 100644 --- a/src/main/java/io/github/azige/moebooruviewer/MoebooruViewer.java +++ b/src/main/java/io/github/azige/moebooruviewer/MoebooruViewer.java @@ -124,10 +124,10 @@ public void showPost(Post post){ } public void showPostById(int id){ - JOptionPane optionPane = new JOptionPane("检索中:" + id, JOptionPane.INFORMATION_MESSAGE); - JButton button = new JButton("取消"); + JOptionPane optionPane = new JOptionPane(Localization.format("retrieval_format", id), JOptionPane.INFORMATION_MESSAGE); + JButton button = new JButton(Localization.getString("cancel")); optionPane.setOptions(new Object[]{button}); - JDialog dialog = optionPane.createDialog(null, "正在检索……"); + JDialog dialog = optionPane.createDialog(null, Localization.getString("retrieving")); button.addActionListener(event -> dialog.dispose()); dialog.setModal(false); dialog.setVisible(true); @@ -139,7 +139,7 @@ public void showPostById(int id){ if (!searchPosts.isEmpty()){ showPostFrame.showPost(searchPosts.get(0)); }else{ - JOptionPane.showMessageDialog(null, "检索的id不存在!"); + JOptionPane.showMessageDialog(null, Localization.getString("id_doesnot_exists")); } } }); diff --git a/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.form b/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.form index dc6d290..4f6da10 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.form +++ b/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.form @@ -10,7 +10,9 @@ - + + + diff --git a/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.java b/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.java index d87ca49..8c0c57d 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.java +++ b/src/main/java/io/github/azige/moebooruviewer/ShowPostFrame.java @@ -107,14 +107,14 @@ public void dispose(){ * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() {//GEN-BEGIN:initComponents postPanePopupMenu = new javax.swing.JPopupMenu(); closeMenuItem = new javax.swing.JMenuItem(); tabbedPane = new javax.swing.JTabbedPane(); - closeMenuItem.setText("关闭此投稿页"); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("io/github/azige/moebooruviewer/Messages"); // NOI18N + closeMenuItem.setText(bundle.getString("close_this_page")); // NOI18N closeMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeMenuItemActionPerformed(evt); @@ -129,7 +129,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); pack(); - }// //GEN-END:initComponents + }//GEN-END:initComponents private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeMenuItemActionPerformed ShowPostPanel postPanel = (ShowPostPanel)tabbedPane.getSelectedComponent(); diff --git a/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.form b/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.form index c362f4e..8900264 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.form +++ b/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.form @@ -10,7 +10,9 @@ - + + + @@ -26,7 +28,9 @@ - + + + @@ -34,7 +38,9 @@ - + + + @@ -86,7 +92,10 @@ - + + + + @@ -120,7 +129,10 @@ - + + + + @@ -137,7 +149,10 @@ - + + + + @@ -154,9 +169,11 @@ - + + + - + @@ -182,7 +199,9 @@ - + + + @@ -213,7 +232,10 @@ - + + + + @@ -230,9 +252,11 @@ - + + + - + @@ -242,7 +266,10 @@ - + + + + @@ -259,9 +286,11 @@ - + + + - + @@ -271,7 +300,10 @@ - + + + + @@ -288,7 +320,9 @@ - + + + diff --git a/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.java b/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.java index 7a1fde8..2d132b2 100644 --- a/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.java +++ b/src/main/java/io/github/azige/moebooruviewer/ShowPostPanel.java @@ -273,7 +273,7 @@ public void mouseClicked(MouseEvent e){ } private JLabel createDownloadLabel(SaveLocation sl, File localFile, String url){ - JLabel label = new JLabel("下载至" + sl.getName()); + JLabel label = new JLabel(Localization.format("download_to_format", sl.getName())); label.setForeground(Color.WHITE); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter(){ @@ -290,7 +290,7 @@ public void mouseClicked(MouseEvent e){ } private JLabel createDownloadToLabel(File localFile, String url){ - JLabel label = new JLabel("下载至..."); + JLabel label = new JLabel(Localization.getString("download_to")); label.setForeground(Color.WHITE); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter(){ @@ -308,7 +308,7 @@ public void mouseClicked(MouseEvent e){ private void makeLabelDone(JLabel label, File file){ label.setEnabled(true); - label.setText("下载完成"); + label.setText(Localization.getString("download_completed")); label.setForeground(COLOR_SUCCESS); Stream.of(label.getMouseListeners()) .forEach(label::removeMouseListener); @@ -332,12 +332,12 @@ private void downloadFile(JLabel label, File localFile, String url, File saveFil makeLabelDone(label, saveFile); }catch (IOException ex){ logger.warn("复制文件异常", ex); - label.setText("复制文件失败"); + label.setText(Localization.getString("failed_to_copy_files")); label.setForeground(COLOR_FAIL); label.setEnabled(true); } }else{ - label.setText("下载中……"); + label.setText(Localization.getString("downloading")); label.setForeground(Color.WHITE); executor.execute(() -> { boolean flag = netIO.cacheFile(saveFile, url, true); @@ -345,7 +345,7 @@ private void downloadFile(JLabel label, File localFile, String url, File saveFil if (flag){ makeLabelDone(label, saveFile); }else{ - label.setText("下载文件失败"); + label.setText(Localization.getString("failed_to_download_file")); label.setForeground(COLOR_FAIL); label.setEnabled(true); } @@ -374,8 +374,7 @@ private void downloadFileTo(JLabel label, File localFile, String url){ * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() {//GEN-BEGIN:initComponents tagPopupMenu = new javax.swing.JPopupMenu(); copyTagNameMenuItem = new javax.swing.JMenuItem(); @@ -398,7 +397,8 @@ private void initComponents() { tagPanel = new javax.swing.JPanel(); tagLoadingLabel = new javax.swing.JLabel(); - copyTagNameMenuItem.setText("复制"); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("io/github/azige/moebooruviewer/Messages"); // NOI18N + copyTagNameMenuItem.setText(bundle.getString("copy")); // NOI18N copyTagNameMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { copyTagNameMenuItemActionPerformed(evt); @@ -406,7 +406,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); tagPopupMenu.add(copyTagNameMenuItem); - copyPostImageMenuItem.setText("复制到剪贴板"); + copyPostImageMenuItem.setText(bundle.getString("copy_to_clipboard")); // NOI18N copyPostImageMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { copyPostImageMenuItemActionPerformed(evt); @@ -414,7 +414,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); postPopupMenu.add(copyPostImageMenuItem); - reloadMenuItem.setText("重新加载"); + reloadMenuItem.setText(bundle.getString("reload")); // NOI18N reloadMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { reloadMenuItemActionPerformed(evt); @@ -429,31 +429,31 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { toolPanel.setOpaque(false); toolPanel.setLayout(new javax.swing.BoxLayout(toolPanel, javax.swing.BoxLayout.Y_AXIS)); - samplePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "预览图", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + samplePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("preview"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N samplePanel.setAlignmentX(0.0F); samplePanel.setOpaque(false); samplePanel.setLayout(new javax.swing.BoxLayout(samplePanel, javax.swing.BoxLayout.Y_AXIS)); toolPanel.add(samplePanel); - jpegPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "JPEG", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + jpegPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "JPEG", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N jpegPanel.setAlignmentX(0.0F); jpegPanel.setOpaque(false); jpegPanel.setLayout(new javax.swing.BoxLayout(jpegPanel, javax.swing.BoxLayout.Y_AXIS)); toolPanel.add(jpegPanel); - originPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "原图", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + originPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("artwork"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N originPanel.setAlignmentX(0.0F); originPanel.setOpaque(false); originPanel.setLayout(new javax.swing.BoxLayout(originPanel, javax.swing.BoxLayout.Y_AXIS)); toolPanel.add(originPanel); - sourcePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "来源", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + sourcePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("source"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N sourcePanel.setOpaque(false); sourcePanel.setLayout(new javax.swing.BoxLayout(sourcePanel, javax.swing.BoxLayout.Y_AXIS)); sourceLinkLabel.setForeground(new java.awt.Color(255, 255, 255)); - sourceLinkLabel.setText("来源链接"); - sourceLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + sourceLinkLabel.setText(bundle.getString("source_link")); // NOI18N + sourceLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); sourcePanel.add(sourceLinkLabel); toolPanel.add(sourcePanel); @@ -465,7 +465,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { postLabel.setForeground(new java.awt.Color(255, 255, 255)); postLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - postLabel.setText("加载中……"); + postLabel.setText(bundle.getString("loading")); // NOI18N postLabel.setPreferredSize(new java.awt.Dimension(800, 600)); centerPanel.add(postLabel, java.awt.BorderLayout.CENTER); @@ -474,41 +474,41 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { infoPanel.setOpaque(false); infoPanel.setLayout(new javax.swing.BoxLayout(infoPanel, javax.swing.BoxLayout.Y_AXIS)); - parentPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "父投稿", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + parentPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("parent_post"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N parentPanel.setOpaque(false); parentPanel.setLayout(new javax.swing.BoxLayout(parentPanel, javax.swing.BoxLayout.Y_AXIS)); parentLinkLabel.setForeground(new java.awt.Color(255, 255, 255)); - parentLinkLabel.setText("点击查看"); - parentLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + parentLinkLabel.setText(bundle.getString("click_to_view")); // NOI18N + parentLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); parentPanel.add(parentLinkLabel); infoPanel.add(parentPanel); - childrenPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "子投稿", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + childrenPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("child_post"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N childrenPanel.setOpaque(false); childrenPanel.setLayout(new javax.swing.BoxLayout(childrenPanel, javax.swing.BoxLayout.Y_AXIS)); childrenLinkLabel.setForeground(new java.awt.Color(255, 255, 255)); - childrenLinkLabel.setText("点击搜索"); - childrenLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + childrenLinkLabel.setText(bundle.getString("click_to_search")); // NOI18N + childrenLinkLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); childrenPanel.add(childrenLinkLabel); infoPanel.add(childrenPanel); - tagPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "标签", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N + tagPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, bundle.getString("tags"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N tagPanel.setOpaque(false); tagPanel.setLayout(new javax.swing.BoxLayout(tagPanel, javax.swing.BoxLayout.Y_AXIS)); tagLoadingLabel.setForeground(new java.awt.Color(255, 255, 255)); - tagLoadingLabel.setText("加载中……"); + tagLoadingLabel.setText(bundle.getString("loading")); // NOI18N tagLoadingLabel.setEnabled(false); tagPanel.add(tagLoadingLabel); infoPanel.add(tagPanel); add(infoPanel, java.awt.BorderLayout.LINE_START); - }// //GEN-END:initComponents + }//GEN-END:initComponents private void copyTagNameMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyTagNameMenuItemActionPerformed if (showingPopupMenuTag != null){ @@ -574,7 +574,7 @@ private void popupMenu(MouseEvent e){ private void loadPost(Post post, boolean force){ postLabel.setIcon(null); - postLabel.setText("加载中……"); + postLabel.setText(Localization.getString("loading")); loadingListeners.forEach(l -> l.loading(new LoadingEvent())); image = null; @@ -586,7 +586,7 @@ private void loadPost(Post post, boolean force){ if (image != null){ showImage(); }else{ - postLabel.setText("加载失败!"); + postLabel.setText(Localization.getString("unable_to_load")); } loadingListeners.forEach(l -> l.done(new LoadingEvent())); } diff --git a/src/main/java/io/github/azige/moebooruviewer/UserSetting.java b/src/main/java/io/github/azige/moebooruviewer/UserSetting.java index e182da9..da18f12 100644 --- a/src/main/java/io/github/azige/moebooruviewer/UserSetting.java +++ b/src/main/java/io/github/azige/moebooruviewer/UserSetting.java @@ -61,10 +61,10 @@ public void setLocation(File location){ public static UserSetting createDefaultSetting(){ UserSetting setting = new UserSetting(); setting.saveLocations = Arrays.asList( - new SaveLocation("壁纸", new File("wallpaper").getAbsoluteFile()), - new SaveLocation("可公开收藏", new File("collections").getAbsoluteFile()), - new SaveLocation("非公开收藏", new File(".collections").getAbsoluteFile()), - new SaveLocation("桌面", FileSystemView.getFileSystemView().getHomeDirectory()) + new SaveLocation(Localization.getString("wallpaper"), new File("wallpaper").getAbsoluteFile()), + new SaveLocation(Localization.getString("collections"), new File("collections").getAbsoluteFile()), + new SaveLocation(Localization.getString("private_collection"), new File(".collections").getAbsoluteFile()), + new SaveLocation(Localization.getString("desktop"), FileSystemView.getFileSystemView().getHomeDirectory()) ); setting.siteConfig = SiteConfig.KONACHAN; setting.pageSize = 20;