OmegaT のメニューバーにフォルダーツリー参照用のメニューを追加します。
Change L10n's key to enum
@@ -39,13 +39,13 @@ | ||
39 | 39 | private ShellLinkMenuItem currentTargetFile; |
40 | 40 | |
41 | 41 | public MenuManager() { |
42 | - root = createLocalizedMenu(L10n.getFoldersMenuLabel()); // Folders menu | |
42 | + root = createLocalizedMenu(L10n.get(L10n.Key.FOLDERS_MENU_LABEL)); // Folders menu | |
43 | 43 | root.addMenuKeyListener(MenuHelper.getMenuKeyListener()); // for opening folder with enter key |
44 | 44 | root.addMenuListener(MenuHelper.getRootMenuListener()); |
45 | 45 | |
46 | 46 | // ProjectRoot |
47 | 47 | try { |
48 | - currentProject = new ShellLinkMenu(L10n.getProjectRootMenuLabel()); | |
48 | + currentProject = new ShellLinkMenu(L10n.get(L10n.Key.PROJECT_ROOT_MENU_LABEL)); | |
49 | 49 | root.add(currentProject.getMenu()); |
50 | 50 | } catch (IOException ex) { |
51 | 51 | Log.log(ex); |
@@ -55,7 +55,7 @@ | ||
55 | 55 | // User Config |
56 | 56 | try { |
57 | 57 | File confDir = new File(StaticUtils.getConfigDir()); |
58 | - root.add(new ShellLinkMenu(confDir, L10n.getUserConfigMenuLabel()).getMenu()); | |
58 | + root.add(new ShellLinkMenu(confDir, L10n.get(L10n.Key.USER_CONFIG_MENU_LABEL)).getMenu()); | |
59 | 59 | } catch (IOException ex) { |
60 | 60 | Log.log(ex); |
61 | 61 | } |
@@ -64,11 +64,11 @@ | ||
64 | 64 | root.add(new JSeparator()); |
65 | 65 | |
66 | 66 | // Current Source File |
67 | - currentSourceFile = new ShellLinkMenuItem(L10n.getSourceDocumentMenuLabel()); | |
67 | + currentSourceFile = new ShellLinkMenuItem(L10n.get(L10n.Key.SOURCE_DOC_MENU_LABEL)); | |
68 | 68 | root.add(currentSourceFile.getMenuItem()); |
69 | 69 | |
70 | 70 | // Current Target File |
71 | - currentTargetFile = new ShellLinkMenuItem(L10n.getTargetDocumentMenuLabel()); | |
71 | + currentTargetFile = new ShellLinkMenuItem(L10n.get(L10n.Key.TARGET_DOC_MENU_LABEL)); | |
72 | 72 | root.add(currentTargetFile.getMenuItem()); |
73 | 73 | |
74 | 74 | // insert Files menu before the last menu (Help menu.) |
@@ -53,7 +53,7 @@ | ||
53 | 53 | this.originalFileLastModified = originalFile.lastModified(); |
54 | 54 | this.temporaryFile = getTempFile(originalFile); |
55 | 55 | this.windowTitle = StaticUtils.format( |
56 | - L10n.getWordWindowCaption(), | |
56 | + L10n.get(L10n.Key.WORD_WINDOW_CAPTION), | |
57 | 57 | originalFile.getName()); |
58 | 58 | this.temporaryFile2 = getTempFile2(this.temporaryFile); |
59 | 59 | } |
@@ -286,7 +286,7 @@ | ||
286 | 286 | } catch (IOException ex) { |
287 | 287 | Log.log(ex); |
288 | 288 | Core.getMainWindow().showMessageDialog(StaticUtils.format( |
289 | - L10n.getErrMsgFileHasNoAssoc(), path)); | |
289 | + L10n.get(L10n.Key.ERROR_FILE_HAS_NO_ASSOC), path)); | |
290 | 290 | } |
291 | 291 | } |
292 | 292 |
@@ -19,49 +19,36 @@ | ||
19 | 19 | import java.util.ResourceBundle; |
20 | 20 | |
21 | 21 | /** |
22 | - * | |
22 | + * Manage localization. | |
23 | + * | |
23 | 24 | * @author Yu Tang |
24 | 25 | */ |
25 | 26 | public class L10n { |
26 | 27 | |
28 | + public enum Key { | |
29 | + // for menu | |
30 | + FOLDERS_MENU_LABEL, | |
31 | + PROJECT_ROOT_MENU_LABEL, | |
32 | + ROOT_MENU_LABEL, | |
33 | + USER_CONFIG_MENU_LABEL, | |
34 | + SOURCE_DOC_MENU_LABEL, | |
35 | + TARGET_DOC_MENU_LABEL, | |
36 | + | |
37 | + // for Word | |
38 | + WORD_WINDOW_CAPTION, | |
39 | + | |
40 | + // for error | |
41 | + ERROR_FILE_HAS_NO_ASSOC | |
42 | + } | |
43 | + | |
27 | 44 | private static final ResourceBundle bundle; |
28 | 45 | |
29 | 46 | static { |
30 | 47 | bundle = ResourceBundle.getBundle(L10n.class.getPackage().getName() + ".Bundle"); |
31 | 48 | } |
32 | - | |
33 | - // for menu | |
34 | 49 | |
35 | - public static String getFoldersMenuLabel() { | |
36 | - return bundle.getString("FOLDERS_MENU_LABEL"); | |
50 | + public static String get(Key key) { | |
51 | + return bundle.getString(key.name()); | |
37 | 52 | } |
38 | - | |
39 | - public static String getProjectRootMenuLabel() { | |
40 | - return bundle.getString("PROJECT_ROOT_MENU_LABEL"); | |
41 | - } | |
42 | - | |
43 | - public static String getUserConfigMenuLabel() { | |
44 | - return bundle.getString("USER_CONFIG_MENU_LABEL"); | |
45 | - } | |
46 | 53 | |
47 | - public static String getSourceDocumentMenuLabel() { | |
48 | - return bundle.getString("SOURCE_DOC_MENU_LABEL"); | |
49 | - } | |
50 | - | |
51 | - public static String getTargetDocumentMenuLabel() { | |
52 | - return bundle.getString("TARGET_DOC_MENU_LABEL"); | |
53 | - } | |
54 | - | |
55 | - // for Word | |
56 | - | |
57 | - public static String getWordWindowCaption() { | |
58 | - return bundle.getString("WORD_WINDOW_CAPTION"); | |
59 | - } | |
60 | - | |
61 | - // for error | |
62 | - | |
63 | - public static String getErrMsgFileHasNoAssoc() { | |
64 | - return bundle.getString("ERROR_FILE_HAS_NO_ASSOC"); | |
65 | - } | |
66 | - | |
67 | 54 | } |