forked from masorange/ClaudeUsageTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalizationManager.swift
More file actions
91 lines (81 loc) · 2.47 KB
/
LocalizationManager.swift
File metadata and controls
91 lines (81 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// LocalizationManager.swift
// Claude Usage Tracker
//
// Copyright © 2025 Sergio Bañuls. All rights reserved.
// Licensed under Personal Use License (Non-Commercial)
//
import Foundation
class LocalizationManager: ObservableObject {
@Published var currentLanguage: Language = .english
enum Language: String, CaseIterable {
case english = "en"
case spanish = "es"
var flag: String {
switch self {
case .english: return "🇺🇸"
case .spanish: return "🇪🇸"
}
}
var name: String {
switch self {
case .english: return "English"
case .spanish: return "Español"
}
}
}
func localized(_ key: LocalizationKey) -> String {
return key.localized(for: currentLanguage)
}
}
enum LocalizationKey {
case title
case byMonth
case byProject
case lastUpdate
case total
case inputTokens
case cacheCreation
case cacheRead
case outputTokens
case input
case output
func localized(for language: LocalizationManager.Language) -> String {
switch language {
case .english:
return englishValue
case .spanish:
return spanishValue
}
}
private var englishValue: String {
switch self {
case .title: return "Claude Usage Tracker"
case .byMonth: return "By Month"
case .byProject: return "By Project"
case .lastUpdate: return "Last update:"
case .total: return "TOTAL"
case .inputTokens: return "Input tokens"
case .cacheCreation: return "Cache creation"
case .cacheRead: return "Cache read"
case .outputTokens: return "Output tokens"
case .input: return "Input"
case .output: return "Output"
}
}
private var spanishValue: String {
switch self {
case .title: return "Seguimiento de Uso de Claude"
case .byMonth: return "Por Mes"
case .byProject: return "Por Proyecto"
case .lastUpdate: return "Última actualización:"
case .total: return "TOTAL"
case .inputTokens: return "Tokens de entrada"
case .cacheCreation: return "Creación de caché"
case .cacheRead: return "Lectura de caché"
case .outputTokens: return "Tokens de salida"
case .input: return "Entrada"
case .output: return "Salida"
}
}
}