From 6555c863bdb73ad3397017d3246d8c75c38a40e6 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Sat, 14 Dec 2024 14:41:54 +0900 Subject: [PATCH] Add information to character section in document inspector (close #1059) --- CHANGELOG.md | 1 + .../Document Window/Document.xcstrings | 356 ++++++++++++++++++ .../Inspector/DocumentInspectorView.swift | 24 +- 3 files changed, 377 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d43f7be9..abb42d421f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Improvements +- Display more Unicode information in the character section in the document inspector. - Improve trimming whitespaces in extracted outline items. diff --git a/CotEditor/Resources/Localizables/Document Window/Document.xcstrings b/CotEditor/Resources/Localizables/Document Window/Document.xcstrings index 7e9493afbe..76feb7f794 100644 --- a/CotEditor/Resources/Localizables/Document Window/Document.xcstrings +++ b/CotEditor/Resources/Localizables/Document Window/Document.xcstrings @@ -354,6 +354,184 @@ } } }, + "Block" : { + "comment" : "label in document inspector", + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Blok" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Block" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "Block" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Bloque" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Sous-ensemble" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Blocco" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "ブロック" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "영역" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Block" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Blok" + } + }, + "pt" : { + "stringUnit" : { + "state" : "translated", + "value" : "Bloco" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Blok" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "区块" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "區段" + } + } + } + }, + "Category" : { + "comment" : "label in document inspector", + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kategorie" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kategorie" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "Category" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Categoría" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Catégorie" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Categoria" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "カテゴリ" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "카테고리" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Categorie" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kategoria" + } + }, + "pt" : { + "stringUnit" : { + "state" : "translated", + "value" : "Categoria" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kategori" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "分类" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "分類" + } + } + } + }, "Character" : { "comment" : "section title in inspector\ntable column header", "localizations" : { @@ -799,6 +977,95 @@ } } }, + "Code Point" : { + "comment" : "label in document inspector", + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kódový bod" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Codepunkt" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "Code Point" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Punto de código" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Point de Code" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Punto di codice" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "コードポイント" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "코드 포인트" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Codepunt" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Punkt kodowy" + } + }, + "pt" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ponto de Código" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kod noktası" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "码位" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "碼位" + } + } + } + }, "Code Points" : { "comment" : "label in document inspector", "localizations" : { @@ -5213,6 +5480,95 @@ } } }, + "Name" : { + "comment" : "label in document inspector", + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Název" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Name" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "Name" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nombre" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nom" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nome" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "名前" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "이름" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Naam" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nazwa" + } + }, + "pt" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nome" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ad" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "名称" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "名稱" + } + } + } + }, "Navigation Bar" : { "comment" : "accessibility label", "localizations" : { diff --git a/CotEditor/Sources/Document Window/Inspector/DocumentInspectorView.swift b/CotEditor/Sources/Document Window/Inspector/DocumentInspectorView.swift index d1710322d3..899f8422ab 100644 --- a/CotEditor/Sources/Document Window/Inspector/DocumentInspectorView.swift +++ b/CotEditor/Sources/Document Window/Inspector/DocumentInspectorView.swift @@ -293,11 +293,15 @@ private struct CharacterPaneView: View { DisclosureGroup(String(localized: "Character", table: "Document", comment: "section title in inspector"), isExpanded: $isExpanded) { Form { - if let character { - LabeledContent(String(localized: "Code Points", table: "Document", - comment: "label in document inspector")) { + if let scalars = self.character?.unicodeScalars { + let label = (scalars.count == 1) + ? String(localized: "Code Point", table: "Document", + comment: "label in document inspector") + : String(localized: "Code Points", table: "Document", + comment: "label in document inspector") + LabeledContent(label) { WrappingHStack { - ForEach(Array(character.unicodeScalars.enumerated()), id: \.offset) { (_, scalar) in + ForEach(Array(scalars.enumerated()), id: \.offset) { (_, scalar) in Text(scalar.codePoint) .monospacedDigit() .textSelection(.enabled) @@ -307,6 +311,18 @@ private struct CharacterPaneView: View { } } } + if scalars.count == 1, let scalar = scalars.first { + OptionalLabeledContent(String(localized: "Name", table: "Document", + comment: "label in document inspector"), + value: scalar.name) + OptionalLabeledContent(String(localized: "Block", table: "Document", + comment: "label in document inspector"), + value: scalar.localizedBlockName) + let category = scalar.properties.generalCategory + OptionalLabeledContent(String(localized: "Category", table: "Document", + comment: "label in document inspector"), + value: "\(category.longName) (\(category.shortName))") + } } else { Text("Not selected", tableName: "Document", comment: "placeholder") .foregroundStyle(.tertiary)