Skip to content

Commit bae8e39

Browse files
committed
fix проблемы с редактированием переводов
+ фикс проблемы с маркировкой автопереводов
1 parent 3811e7b commit bae8e39

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

sources/LocalizationEditor/Models/Localization.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class Localization {
2525
func update(key: String, value: String, message: String?) {
2626
if let existing = translations.first(where: { $0.key == key }) {
2727
existing.update(newValue: value)
28+
existing.update(message: message)
2829
return
2930
}
3031

sources/LocalizationEditor/Models/LocalizationString.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
final class LocalizationString {
1515
let key: String
1616
private(set) var value: String
17-
private (set) var message: String?
17+
private(set) var message: String?
1818

1919
init(key: String, value: String, message: String?) {
2020
self.key = key
@@ -23,10 +23,10 @@ final class LocalizationString {
2323
}
2424

2525
func update(newValue: String) {
26-
value = newValue
26+
self.value = newValue
2727
}
2828

29-
func updateMessage(_ message: String?) {
29+
func update(message: String?) {
3030
self.message = message
3131
}
3232
}

sources/LocalizationEditor/Providers/LocalizationsDataSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ final class LocalizationsDataSource: NSObject {
263263
with: "",
264264
message: locString?.message?.replacingOccurrences(of: kAutotranslatedTag, with: ""))
265265
locString?.update(newValue: "")
266-
locString?.updateMessage(locString?.message?.replacingOccurrences(of: kAutotranslatedTag, with: ""))
266+
locString?.update(message: locString?.message?.replacingOccurrences(of: kAutotranslatedTag, with: ""))
267267
}
268268
}
269269

sources/LocalizationEditor/Services/AutoTranslator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class AutoTranslator {
4747
let res = try translator.translateSync(text: stringToTranslate, targetLang: locLang)
4848
var message = locString?.message ?? ""
4949
if !message.contains(kAutotranslatedTag) {
50-
message = [message, kAutotranslatedTag].joined(separator: " ")
50+
message = [message, kAutotranslatedTag]
51+
.joined(separator: " ")
52+
.trimmingCharacters(in: .whitespaces)
5153
}
5254
translated[locKey]?[locLang] = .init(key: locKey, value: res, message: message)
5355
}

sources/LocalizationEditor/UI/Cells/LocalizationCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extension LocalizationCell: NSTextFieldDelegate {
6464
}
6565

6666
setStateUI()
67-
value.update(newValue: valueTextField.stringValue)
6867
delegate?.userDidUpdateLocalizationString(language: language, key: value.key, with: valueTextField.stringValue, message: value.message)
68+
value.update(newValue: valueTextField.stringValue)
6969
}
7070
}

0 commit comments

Comments
 (0)