OSDN Git Service

Localizableを使ってローカライズするように変更
authormasakih <masakih@users.sourceforge.jp>
Sun, 1 Oct 2017 15:24:56 +0000 (00:24 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 1 Oct 2017 15:24:56 +0000 (00:24 +0900)
19 files changed:
KCD/ActinKindTransformer.swift
KCD/AirbasePlaneStateTransformer.swift
KCD/BridgeViewController.swift
KCD/BroserWindowController.swift
KCD/DocksViewController.swift
KCD/ExternalBrowserWindowController.swift
KCD/GameViewController.swift
KCD/HistoryTableViewController.swift
KCD/KenzoDockStatus.swift
KCD/LengTransformer.swift
KCD/LocalizedStrings.swift [new file with mode: 0644]
KCD/MissionStatus.swift
KCD/NyukyoDockStatus.swift
KCD/SlotItemWindowController.swift
KCD/SokuTransformer.swift
KCD/StoreCreateSlotItemHistoryCommand.swift
KCD/TimeSignalNotifier.swift
KCD/UpgradableShipsWindowController.swift
KCD/WindowManager.swift

index 5326d52..47a68fa 100644 (file)
@@ -33,20 +33,15 @@ final class ActinKindTransformer: ValueTransformer {
         }
         
         switch type {
-        case .standBy:
-            return NSLocalizedString("StandBy", comment: "Airbase action kind")
+        case .standBy: return LocalizedStrings.standBy.string
             
-        case .sortie:
-            return NSLocalizedString("Sortie", comment: "Airbase action kind")
+        case .sortie: return LocalizedStrings.sortie.string
             
-        case .airDifence:
-            return NSLocalizedString("Air Difence", comment: "Airbase action kind")
+        case .airDifence: return LocalizedStrings.airDifense.string
             
-        case .shelter:
-            return NSLocalizedString("Shelter", comment: "Airbase action kind")
+        case .shelter: return LocalizedStrings.shelter.string
             
-        case .rest:
-            return NSLocalizedString("Rest", comment: "Airbase action kind")
+        case .rest: return LocalizedStrings.rest.string
         }
     }
 }
index f7c12ff..fa838cd 100644 (file)
@@ -19,6 +19,6 @@ final class AirbasePlaneStateTransformer: ValueTransformer {
         
         guard let v = value as? Int, v == 2 else { return nil }
         
-        return NSLocalizedString("rotating", comment: "AirbasePlaneStateTransformer")
+        return LocalizedStrings.rotating.string
     }
 }
index 2839561..fb50f7f 100644 (file)
@@ -61,7 +61,7 @@ extension BridgeViewController: NSSharingServicePickerDelegate, ScreenshotSharin
     
     private var tagString: String? {
         
-        let tag = NSLocalizedString("kancolle", comment: "kancolle twitter hash tag")
+        let tag = LocalizedStrings.tweetTag.string
         if tag == "" { return "" }
         
         return "#\(tag)"
index 28278f7..f692124 100644 (file)
@@ -381,11 +381,11 @@ extension BroserWindowController {
         case Selector.showHideCombinedView:
             if isCombinedMode {
                 
-                menuItem.title = NSLocalizedString("Hide Combined View", comment: "View menu, hide combined view")
+                menuItem.title = LocalizedStrings.hideCombinedView.string
                 
             } else {
                 
-                menuItem.title = NSLocalizedString("Show Combined View", comment: "View menu, show combined view")
+                menuItem.title = LocalizedStrings.showCombinedView.string
                 
             }
             if fleetViewPosition == .oldStyle { return false }
index b3a1cf3..612419e 100644 (file)
@@ -132,18 +132,18 @@ final class DocksViewController: MainTabVIewItemViewController {
         
         if battleCellNumber == 0 {
             
-            let format = NSLocalizedString("%@ in sortie into %@ (%@)", comment: "Sortie")
+            let format = LocalizedStrings.sortieInfomation.string
             
             return String(format: format, arguments: [fleetName, areaName, areaNumber])
         }
         if isBossCell {
             
-            let format = NSLocalizedString("%@ battle against the enemy main fleet at %@ war zone in %@ (%@) now", comment: "Sortie")
+            let format = LocalizedStrings.battleWithBOSS.string
             
             return String(format: format, arguments: [fleetName, battleCellNumber as NSNumber, areaName, areaNumber])
         }
         
-        let format = NSLocalizedString("%@ battle at %@ war zone in %@ (%@) now", comment: "Sortie")
+        let format = LocalizedStrings.battleInformation.string
         
         return String(format: format, arguments: [fleetName, battleCellNumber as NSNumber, areaName, areaNumber])
     }
index c8de017..1684ade 100644 (file)
@@ -205,11 +205,11 @@ extension ExternalBrowserWindowController {
         case Selector.showBookmark:
             if showsBookmarkList() {
                 
-                menuItem.title = NSLocalizedString("Hide Bookmark", comment: "Menu item title, Hide Bookmark")
+                menuItem.title = LocalizedStrings.hideBookmark.string
                 
             } else {
                 
-                menuItem.title = NSLocalizedString("Show Bookmark", comment: "Menu item title, Show Bookmark")
+                menuItem.title = LocalizedStrings.showBookmark.string
             }
             return true
             
index 646340a..6c1bd77 100644 (file)
@@ -84,8 +84,8 @@ final class GameViewController: NSViewController {
             let untilDate = prevDate.addingTimeInterval(1 * 60)
             let date = DateFormatter.localizedString(from: untilDate, dateStyle: .none, timeStyle: .medium)
             let alert = NSAlert()
-            alert.messageText = NSLocalizedString("Reload interval is too short?", comment: "")
-            let format = NSLocalizedString("Reload interval is too short.\nWait until %@.", comment: "")
+            alert.messageText = LocalizedStrings.reloadTimeShortenMessage.string
+            let format = LocalizedStrings.reloadTimeShortenInfo.string
             alert.informativeText = String(format: format, date)
             alert.runModal()
             
@@ -105,7 +105,7 @@ final class GameViewController: NSViewController {
         guard let panelWindow = panel.window else { return }
         
         panel.title = ""
-        panel.message = NSLocalizedString("Deleting caches...", comment: "Deleting caches...")
+        panel.message = LocalizedStrings.deletingCacheInfo.string
         panel.animate = true
         
         window.beginSheet(panelWindow) { _ in NSSound(named: NSSound.Name("Submarine"))?.play() }
@@ -136,13 +136,13 @@ final class GameViewController: NSViewController {
             
             switch frameURL {
             case GameViewController.gamePageURL:
-                menuItem.title = NSLocalizedString("Reload", comment: "Reload menu, reload")
+                menuItem.title = LocalizedStrings.reload.string
                 
             case let s where s.hasPrefix(GameViewController.loginPageURLPrefix):
-                menuItem.title = NSLocalizedString("Reload", comment: "Reload menu, reload")
+                menuItem.title = LocalizedStrings.reload.string
                 
             default:
-                menuItem.title = NSLocalizedString("Back To Game", comment: "Reload menu, back to game")
+                menuItem.title = LocalizedStrings.backToGame.string
             }
             
             return true
index 9242834..30fbd9d 100644 (file)
@@ -101,11 +101,11 @@ class HistoryTableViewController: NSViewController {
             menuItem.isEnabled = true
             if clickedObject.mark {
                 
-                menuItem.title = NSLocalizedString("Remove mark", comment: "Remove history mark.")
+                menuItem.title = LocalizedStrings.removeMark.string
                 
             } else {
                 
-                menuItem.title = NSLocalizedString("Add mark", comment: "Add history mark.")
+                menuItem.title = LocalizedStrings.addMark.string
             }
         }
         
index 06debec..36bfc79 100644 (file)
@@ -94,7 +94,7 @@ final class KenzoDockStatus: NSObject {
         if diff > 0 { return }
         
         let notification = NSUserNotification()
-        let format = NSLocalizedString("It Will Finish Build at No.%@.", comment: "It Will Finish Build at No.%@.")
+        let format = LocalizedStrings.buildingWillFinish.string
         notification.title = String(format: format, number as NSNumber)
         notification.informativeText = notification.title
         
index 14b049e..a6331ff 100644 (file)
@@ -28,17 +28,13 @@ final class LengTransformer: ValueTransformer {
         guard let v = value as? Int, let type = LengType(rawValue: v) else { return nil }
         
         switch type {
-        case .short:
-            return NSLocalizedString("Short", comment: "Range, short")
+        case .short: return LocalizedStrings.short.string
             
-        case .middle:
-            return NSLocalizedString("Middle", comment: "Range, middle")
+        case .middle: return LocalizedStrings.middle.string
             
-        case .long:
-            return NSLocalizedString("Long", comment: "Range, long")
+        case .long: return LocalizedStrings.long.string
             
-        case .overLong:
-            return NSLocalizedString("Very Long", comment: "Range, very long")
+        case .overLong: return LocalizedStrings.overLong.string
         }
     }
 }
diff --git a/KCD/LocalizedStrings.swift b/KCD/LocalizedStrings.swift
new file mode 100644 (file)
index 0000000..f752577
--- /dev/null
@@ -0,0 +1,172 @@
+//
+//  LocalizedStrings.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/10/01.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Foundation
+
+struct LocalizedStrings {}
+
+/// WindowManager
+extension LocalizedStrings {
+    
+    /// Menu itmes
+    static let showHistory = LocalizedString("Show History", comment: "Show History")
+    static let hideHistory = LocalizedString("Hide History", comment: "Hide History")
+    static let showSlotItem = LocalizedString("Show Slot Item", comment: "Show Slot Item")
+    static let hideSlotItem = LocalizedString("Hide Slot Item", comment: "Hide Slot Item")
+    static let showUpgradableShips = LocalizedString("Show Upgradable Ships", comment: "Show Upgradable Ships")
+    static let hideUpgradableShips = LocalizedString("Hide Upgradable Ships", comment: "Hide Upgradable Ships")
+    static let showScreenshotList = LocalizedString("Show Screenshot List", comment: "Show Screenshot List")
+    static let hideScreenshotList = LocalizedString("Hide Screenshot List", comment: "Hide Screenshot List")
+    static let showAirbaseInfo = LocalizedString("Show Air Base Info", comment: "Show Air Base Info")
+    static let hideAirbaseInfo = LocalizedString("Hide Air Base Info", comment: "Hide Air Base Info")
+    
+}
+
+/// SokuTransformer
+extension LocalizedStrings {
+    
+    static let slow = LocalizedString("Slow", comment: "Speed, slow")
+    static let fast = LocalizedString("Fast", comment: "Speed, fast")
+    static let faster = LocalizedString("Faster", comment: "Speed, faster")
+    static let fastest = LocalizedString("Fastest", comment: "Speed, fastest")
+    
+}
+
+/// LengTransformer
+extension LocalizedStrings {
+    
+    static let short = LocalizedString("Short", comment: "Range, short")
+    static let middle = LocalizedString("Middle", comment: "Range, middle")
+    static let long = LocalizedString("Long", comment: "Range, long")
+    static let overLong = LocalizedString("Very Long", comment: "Range, very long")
+    
+}
+
+/// ActinKindTransformer
+extension LocalizedStrings {
+    
+    static let standBy = LocalizedString("StandBy", comment: "Airbase action kind")
+    static let sortie = LocalizedString("Sortie", comment: "Airbase action kind")
+    static let airDifense = LocalizedString("Air Difence", comment: "Airbase action kind")
+    static let shelter = LocalizedString("Shelter", comment: "Airbase action kind")
+    static let rest = LocalizedString("Rest", comment: "Airbase action kind")
+    
+}
+
+/// AirbasePlaneStateTransformer
+extension LocalizedStrings {
+    
+    static let rotating = LocalizedString("rotating", comment: "AirbasePlaneStateTransformer")
+}
+
+/// MissionStatus
+extension LocalizedStrings {
+    
+    static let missionWillReturnMessage = LocalizedString("%@ Will Return From Mission.", comment: "%@ Will Return From Mission.")
+    static let missionWillReturnInformation = LocalizedString("%@ Will Return From %@.", comment: "%@ Will Return From %@.")
+    
+}
+
+/// NyukyoDockStatus
+extension LocalizedStrings {
+    
+    static let dockingWillFinish = LocalizedString("%@ Will Finish Docking.", comment: "%@ Will Finish Docking.")
+    
+}
+
+/// KenzoDockStatus
+extension LocalizedStrings {
+    
+    static let buildingWillFinish = LocalizedString("It Will Finish Build at No.%@.", comment: "It Will Finish Build at No.%@.")
+    
+}
+
+/// TimeSignalNotifier
+extension LocalizedStrings {
+    
+    static let timerSIgnalMessage = LocalizedString("It is soon %zd o'clock.", comment: "It is soon %zd o'clock.")
+    
+}
+
+/// StoreCreateSlotItemHistoryCommand
+extension LocalizedStrings {
+    
+    static let failDevelop = LocalizedString("fail to develop", comment: "fail to develop")
+    
+}
+
+/// BridgeViewController
+extension LocalizedStrings {
+    
+    static let tweetTag = LocalizedString("kancolle", comment: "kancolle twitter hash tag")
+    
+}
+
+/// BroserWindowController
+extension LocalizedStrings {
+    
+    /// Menu items
+    static let showCombinedView = LocalizedString("Show Combined View", comment: "View menu, show combined view")
+    static let hideCombinedView = LocalizedString("Hide Combined View", comment: "View menu, hide combined view")
+    
+}
+
+/// GameViewController
+extension LocalizedStrings {
+    
+    /// Menu items
+    static let reload = LocalizedString("Reload", comment: "Reload menu, reload")
+    static let backToGame = LocalizedString("Back To Game", comment: "Reload menu, back to game")
+    
+    /// Others
+    static let reloadTimeShortenMessage = LocalizedString("Reload interval is too short?", comment: "")
+    static let reloadTimeShortenInfo = LocalizedString("Reload interval is too short.\nWait until %@.", comment: "")
+    static let deletingCacheInfo = LocalizedString("Deleting caches...", comment: "Deleting caches...")
+}
+
+/// DocksViewController
+extension LocalizedStrings {
+    
+    static let sortieInfomation = LocalizedString("%@ in sortie into %@ (%@)", comment: "Sortie")
+    static let battleWithBOSS = LocalizedString("%@ battle against the enemy main fleet at %@ war zone in %@ (%@) now", comment: "Sortie")
+    static let battleInformation = LocalizedString("%@ battle at %@ war zone in %@ (%@) now", comment: "Sortie")
+}
+
+/// HistoryTableViewController
+extension LocalizedStrings {
+    
+    static let addMark = LocalizedString("Add mark", comment: "Add history mark.")
+    static let removeMark = LocalizedString("Remove mark", comment: "Remove history mark.")
+    
+}
+
+/// SlotItemWindowController
+extension LocalizedStrings {
+    
+    static let allEquipment = LocalizedString("All", comment: "show equipment type All")
+    static let equiped = LocalizedString("Equiped", comment: "show equipment type Equiped")
+    static let unequiped = LocalizedString("Unequiped", comment: "show equipment type Unequiped")
+    
+}
+
+/// UpgradableShipsWindowController
+extension LocalizedStrings {
+    
+    static let showKanmusu = LocalizedString("Show Kanmusu", comment: "UpgradableShipsWindowController menu item")
+    static let hideKanmusu = LocalizedString("Hide Kanmusu", comment: "UpgradableShipsWindowController menu item")
+    
+}
+
+/// ExternalBrowserWindowController
+extension LocalizedStrings {
+    
+    /// Menu Items
+    static let showBookmark = LocalizedString("Show Bookmark", comment: "Menu item title, Show Bookmark")
+    static let hideBookmark = LocalizedString("Hide Bookmark", comment: "Menu item title, Hide Bookmark")
+    
+}
index 2f358dd..0051902 100644 (file)
@@ -127,9 +127,9 @@ final class MissionStatus: NSObject {
         guard let fleetName = fleetName else { return }
         
         let notification = NSUserNotification()
-        let format = NSLocalizedString("%@ Will Return From Mission.", comment: "%@ Will Return From Mission.")
+        let format = LocalizedStrings.missionWillReturnMessage.string
         notification.title = String(format: format, fleetName)
-        let txtFormat = NSLocalizedString("%@ Will Return From %@.", comment: "%@ Will Return From %@.")
+        let txtFormat = LocalizedStrings.missionWillReturnInformation.string
         notification.informativeText = String(format: txtFormat, fleetName, name!)
         
         if UserDefaults.standard[.playFinishMissionSound] {
index 93e92d0..32ec37b 100644 (file)
@@ -120,7 +120,7 @@ final class NyukyoDockStatus: NSObject {
         if diff >= 1 * 60 { return }
         
         let notification = NSUserNotification()
-        let format = NSLocalizedString("%@ Will Finish Docking.", comment: "%@ Will Finish Docking.")
+        let format = LocalizedStrings.dockingWillFinish.string
         notification.title = String(format: format, name)
         notification.informativeText = notification.title
         
index 5ec7e66..9ae60f7 100644 (file)
@@ -56,14 +56,12 @@ final class SlotItemWindowController: NSWindowController {
     @objc var showEquipmentTypeTitle: String {
         
         switch UserDefaults.standard[.showEquipmentType] {
-        case .all:
-            return NSLocalizedString("All", comment: "show equipment type All")
             
-        case .nonEquiped:
-            return NSLocalizedString("Unequiped", comment: "show equipment type Unequiped")
+        case .all: return LocalizedStrings.allEquipment.string
             
-        case .equiped:
-            return NSLocalizedString("Equiped", comment: "show equipment type Equiped")
+        case .nonEquiped: return LocalizedStrings.unequiped.string
+            
+        case .equiped: return LocalizedStrings.equiped.string
         }
     }
     
index 7ad37a2..0a8f3bf 100644 (file)
@@ -28,17 +28,13 @@ final class SokuTransformer: ValueTransformer {
         guard let v = value as? Int, let type = SokuType(rawValue: v) else { return nil }
         
         switch type {
-        case .slow:
-            return NSLocalizedString("Slow", comment: "Speed, slow")
+        case .slow: return LocalizedStrings.slow.string
             
-        case .fast:
-            return NSLocalizedString("Fast", comment: "Speed, fast")
+        case .fast: return LocalizedStrings.fast.string
             
-        case .faster:
-            return NSLocalizedString("Faster", comment: "Speed, faster")
+        case .faster: return LocalizedStrings.faster.string
             
-        case .fastest:
-            return NSLocalizedString("Fastest", comment: "Speed, fastest")
+        case .fastest: return LocalizedStrings.fastest.string
         }
     }
 }
index 9a414e2..48d8e07 100644 (file)
@@ -60,7 +60,7 @@ final class StoreCreateSlotItemHistoryCommand: JSONCommand {
         
         if sccess == 0 {
             
-            return NSLocalizedString("fail to develop", comment: "fail to develop")
+            return LocalizedStrings.failDevelop.string
             
         }
         
index 53d4e69..7ffbcd0 100644 (file)
@@ -52,7 +52,7 @@ final class TimeSignalNotifier: NSObject {
         
         let notification = NSUserNotification()
         let hour = cal.component(.hour, from: now)
-        let format = NSLocalizedString("It is soon %zd o'clock.", comment: "It is soon %zd o'clock.")
+        let format = LocalizedStrings.timerSIgnalMessage.string
         notification.title = String(format: format, hour + 1)
         notification.informativeText = notification.title
         
index 4f3b4a0..531316c 100644 (file)
@@ -161,11 +161,11 @@ final class UpgradableShipsWindowController: NSWindowController {
             let shipID = ships[row].id
             if isExcludeShipID(shipID) {
                 
-                menuItem.title = NSLocalizedString("Show Kanmusu", comment: "UpgradableShipsWindowController menu item")
+                menuItem.title = LocalizedStrings.showKanmusu.string
                 
             } else {
                 
-                menuItem.title = NSLocalizedString("Hide Kanmusu", comment: "UpgradableShipsWindowController menu item")
+                menuItem.title = LocalizedStrings.hideKanmusu.string
             }
             
             return true
index ba05b99..0c9bcf0 100644 (file)
@@ -332,36 +332,36 @@ extension WindowManager {
         case Selector.showHideHistory:
             setTitle(menuItem,
                      historyWindowController.window,
-                     NSLocalizedString("Show History", comment: "Show History"),
-                     NSLocalizedString("Hide History", comment: "Hide History"))
+                     LocalizedStrings.showHistory.string,
+                     LocalizedStrings.hideHistory.string)
             return true
             
         case Selector.showHideSlotItemWindow:
             setTitle(menuItem,
                      slotItemWindowController.window,
-                     NSLocalizedString("Show Slot Item", comment: "Show Slot Item"),
-                     NSLocalizedString("Hide Slot Item", comment: "Hide Slot Item"))
+                     LocalizedStrings.showSlotItem.string,
+                     LocalizedStrings.hideSlotItem.string)
             return true
             
         case Selector.showHideUpgradableShipWindow:
             setTitle(menuItem,
                      upgradableShipWindowController.window,
-                     NSLocalizedString("Show Upgradable Ships", comment: "Show Upgradable Ships"),
-                     NSLocalizedString("Hide Upgradable Ships", comment: "Hide Upgradable Ships"))
+                     LocalizedStrings.showUpgradableShips.string,
+                     LocalizedStrings.hideUpgradableShips.string)
             return true
             
         case Selector.showHideScreenshotListWindow:
             setTitle(menuItem,
                      screenshotListWindowController.window,
-                     NSLocalizedString("Show Screenshot List", comment: "Show Screenshot List"),
-                     NSLocalizedString("Hide Screenshot List", comment: "Hide Screenshot List"))
+                     LocalizedStrings.showScreenshotList.string,
+                     LocalizedStrings.hideScreenshotList.string)
             return true
             
         case Selector.showHideAirBaseInfoWindow:
             setTitle(menuItem,
                      airBaseWindowController.window,
-                     NSLocalizedString("Show Air Base Info", comment: "Show Air Base Info"),
-                     NSLocalizedString("Hide Air Base Info", comment: "Hide Air Base Info"))
+                     LocalizedStrings.showAirbaseInfo.string,
+                     LocalizedStrings.hideAirbaseInfo.string)
             return true
             
         case Selector.showHidePreferencePanle: