Skip to content

Commit

Permalink
Refactor localization
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Mar 4, 2024
1 parent 009be5d commit d9626b0
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 117 deletions.
5 changes: 2 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ This release removes all deprecated code and cleans up the library.

* All previously deprecated code has been deleted.

* `RichTextContextFocusedValueKey` has been renamed to `RichTextContext.FocusedValueKey`
* `RichTextContextFocusedValueKey` has been renamed to `RichTextContext.FocusedValueKey`.
* `RichTextEditor` is now configured and styled with view modifiers instead of with the initializer.
* `RichTextFont` pickers are now configured with a shared view modifier instead of with the initializer.
* `RichTextKeyboardToolbar` is now configured and styled with view modifiers instead of with the initializer.


* `RTKL10n` has renamed many localization keys.



Expand Down
6 changes: 3 additions & 3 deletions Sources/RichTextKit/Commands/RichTextCommand+FormatMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public extension RichTextCommand.FormatMenu {
public var body: some View {
switch self {
case .font:
Menu(RTKL10n.menuFont.text) {
Menu(RTKL10n.font.text) {
Group(styles: .all)
Divider()
Group(fontSize: true)
Expand All @@ -79,15 +79,15 @@ public extension RichTextCommand.FormatMenu {
Group(alignments: .all)
}
case .indent:
Menu(RTKL10n.menuIndent.text) {
Menu(RTKL10n.indent.text) {
Group(indent: true)
}
case .lineSpacing:
Menu(RTKL10n.lineSpacing.text) {
Group(lineSpacing: true)
}
case .superscript:
Menu(RTKL10n.menuSuperscript.text) {
Menu(RTKL10n.superscript.text) {
Group(superscript: true)
}
}
Expand Down
55 changes: 29 additions & 26 deletions Sources/RichTextKit/Localization/RTKL10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public enum RTKL10n: String, CaseIterable, Identifiable {

font,
fontSize,
fontSizeIncrease,
fontSizeIncreaseDescription,
fontSizeDecrease,
fontSizeDecreaseDescription,

color,
foregroundColor,
Expand All @@ -27,42 +31,35 @@ public enum RTKL10n: String, CaseIterable, Identifiable {

actionCopy,
actionDismissKeyboard,
actionFontSizeIncrease,
actionFontSizeDecrease,
actionIndentIncrease,
actionIndentDecrease,
actionLineSpacingIncrease,
actionLineSpacingDecrease,
actionPrint,
actionRedoLatestChange,
actionSuperscriptIncrease,
actionSuperscriptDecrease,
actionUndoLatestChange,

fileFormatRtk,
fileFormatPdf,
fileFormatRtf,
fileFormatTxt,

indent,
indentIncrease,
indentIncreaseDescription,
indentDecrease,
indentDecreaseDescription,

lineSpacing,
lineSpacingIncrease,
lineSpacingIncreaseDescription,
lineSpacingDecrease,

lineSpacingDecreaseDescription,

menuExport,
menuExportAs,
menuFont,
menuFormat,
menuIndent,
menuIndentIncrease,
menuIndentDecrease,
menuPrint,
menuSave,
menuSaveAs,
menuShare,
menuShareAs,
menuSuperscript,
menuSuperscriptIncrease,
menuSuperscriptDecrease,
menuText,

highlightedRange,
Expand All @@ -79,6 +76,12 @@ public enum RTKL10n: String, CaseIterable, Identifiable {
styleItalic,
styleStrikethrough,
styleUnderlined,

superscript,
superscriptIncrease,
superscriptIncreaseDescription,
superscriptDecrease,
superscriptDecreaseDescription,

textAlignment,
textAlignmentLeft,
Expand All @@ -93,38 +96,38 @@ public extension RTKL10n {
_ points: Int
) -> RTKL10n {
points < 0 ?
.actionFontSizeDecrease :
.actionFontSizeIncrease
.fontSizeDecreaseDescription :
.fontSizeIncreaseDescription
}

static func actionStepIndent(
_ points: Double
) -> RTKL10n {
points < 0 ?
.actionIndentDecrease :
.actionIndentIncrease
.indentDecreaseDescription :
.indentIncreaseDescription
}

static func actionStepLineSpacing(
_ points: CGFloat
) -> RTKL10n {
points < 0 ?
.actionLineSpacingDecrease :
.actionLineSpacingIncrease
.lineSpacingDecreaseDescription :
.lineSpacingIncreaseDescription
}

static func actionStepSuperscript(
_ steps: Int
) -> RTKL10n {
steps < 0 ?
.actionSuperscriptDecrease :
.actionSuperscriptIncrease
.superscriptDecreaseDescription :
.superscriptIncreaseDescription
}

static func menuIndent(_ points: Double) -> RTKL10n {
points < 0 ?
.menuIndentDecrease :
.menuIndentIncrease
.indentDecrease :
.indentIncrease
}
}

Expand Down
36 changes: 19 additions & 17 deletions Sources/RichTextKit/Resources/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

"font" = "Skrifttype";
"fontSize" = "Skriftstørrelse";
"fontSizeIncrease" = "Større";
"fontSizeIncreaseDescription" = "Øge skriftstørrelsen";
"fontSizeDecrease" = "Mindre";
"fontSizeDecreaseDescription" = "Mindske skriftstørrelsen";

"color" = "Farve";
"foregroundColor" = "Tekst";
Expand All @@ -23,44 +27,35 @@

"actionCopy" = "Kopiere";
"actionDismissKeyboard" = "Luk tastaturet";
"actionFontSizeIncrease" = "Øge skriftstørrelsen";
"actionFontSizeDecrease" = "Mindske skriftstørrelsen";
"actionIndentIncrease" = "Øge indrag";
"actionIndentDecrease" = "Mindske indrag";
"actionLineSpacingIncrease" = "Øge linjeafstand";
"actionLineSpacingDecrease" = "Mindske linjeafstand";
"actionPrint" = "Udskriv";
"actionRedoLatestChange" = "Lave om";
"actionSuperscriptIncrease" = "Increase Superscript";
"actionSuperscriptDecrease" = "Decrease Superscript";
"actionUndoLatestChange" = "Fortryd";

"fileFormatRtk" = "Rich Text Kit (.rtk)";
"fileFormatPdf" = "PDF (.pdf)";
"fileFormatRtf" = "Formateret tekst (.rtf)";
"fileFormatTxt" = "Ren tekst (.txt)";

"indent" = "Indrag";
"indentIncrease" = "Øge";
"indentIncreaseDescription" = "Øge indrag";
"indentDecrease" = "Mindske";
"indentDecreaseDescription" = "Mindske indrag";

"lineSpacing" = "Linjeafstand";
"lineSpacingIncrease" = "Increase";
"lineSpacingIncreaseDescription" = "Øge linjeafstand";
"lineSpacingDecrease" = "Decrease";
"lineSpacingDecreaseDescription" = "Mindske linjeafstand";

"menuExport" = "Eksportere";
"menuExportAs" = "Eksportere som...";
"menuFont" = "Skrifttype";
"menuFontSizeIncrease" = "Større";
"menuFontSizeDecrease" = "Mindre";
"menuFormat" = "Format";
"menuIndent" = "Indrag";
"menuIndentIncrease" = "Øge";
"menuIndentDecrease" = "Mindske";
"menuPrint" = "Udskriv...";
"menuSave" = "Spare";
"menuSaveAs" = "Spare som...";
"menuShare" = "Del";
"menuShareAs" = "Del som...";
"menuSuperscript" = "Baslinje";
"menuSuperscriptIncrease" = "Øge";
"menuSuperscriptDecrease" = "Mindske";
"menuText" = "Tekst";

"highlightedRange" = "Highlight Range";
Expand All @@ -77,6 +72,13 @@
"styleStrikethrough" = "Gennemstreget";
"styleUnderlined" = "Understregning";

"superscript" = "Baslinje";
"superscriptIncrease" = "Øge";
"superscriptIncreaseDescription" = "Øge Baslinje";
"superscriptDecrease" = "Mindske";
"superscriptDecreaseDescription" = "Mindske Baslinje";


"textAlignment" = "Tekstjustering";
"textAlignmentLeft" = "Venstrejusteret";
"textAlignmentRight" = "Højrejuster";
Expand Down
35 changes: 18 additions & 17 deletions Sources/RichTextKit/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

"font" = "Schriftart";
"fontSize" = "Schriftgröße";
"fontSizeIncrease" = "Größer";
"fontSizeIncreaseDescription" = "Schriftgröße vergrößern";
"fontSizeDecrease" = "Kleiner";
"fontSizeDecreaseDescription" = "Schriftgröße verkleinern";

"color" = "Farbe";
"foregroundColor" = "Text";
Expand All @@ -23,44 +27,35 @@

"actionCopy" = "Kopieren";
"actionDismissKeyboard" = "Tastatur schließen";
"actionFontSizeIncrease" = "Schriftgröße vergrößern";
"actionFontSizeDecrease" = "Schriftgröße verkleinern";
"actionIndentIncrease" = "Indent vergrößern";
"actionIndentDecrease" = "Indent verkleinern";
"actionLineSpacingIncrease" = "Zeilenabstand Vergrößern";
"actionLineSpacingDecrease" = "Zeilenabstand Verkleinern";
"actionPrint" = "Drucken";
"actionRedoLatestChange" = "Rückgängig";
"actionSuperscriptIncrease" = "Increase Superscript";
"actionSuperscriptDecrease" = "Decrease Superscript";
"actionUndoLatestChange" = "Wiederholen";

"fileFormatRtk" = "Rich Text Kit (.rtk)";
"fileFormatPdf" = "PDF (.pdf)";
"fileFormatRtf" = "Formatierter Text (.rtf)";
"fileFormatTxt" = "Klartext (.txt)";

"indent" = "Indent";
"indentIncrease" = "Vergrößern";
"indentIncreaseDescription" = "Indent vergrößern";
"indentDecrease" = "Verkleinern";
"indentDecreaseDescription" = "Indent verkleinern";

"lineSpacing" = "Zeilenabstand";
"lineSpacingIncrease" = "Vergrößern";
"lineSpacingIncreaseDescription" = "Zeilenabstand Vergrößern";
"lineSpacingDecrease" = "Verkleinern";
"lineSpacingDecreaseDescription" = "Zeilenabstand Verkleinern";

"menuExport" = "Exportieren";
"menuExportAs" = "Exportieren als...";
"menuFont" = "Schriftart";
"menuFontSizeIncrease" = "Größer";
"menuFontSizeDecrease" = "Kleiner";
"menuFormat" = "Format";
"menuIndent" = "Indent";
"menuIndentIncrease" = "Vergrößern";
"menuIndentDecrease" = "Verkleinern";
"menuPrint" = "Drucken...";
"menuSave" = "Speichern";
"menuSaveAs" = "Speichern als...";
"menuShare" = "Teilen";
"menuShareAs" = "Teilen als...";
"menuSuperscript" = "Grundlinie";
"menuSuperscriptIncrease" = "Øge";
"menuSuperscriptDecrease" = "Mindske";
"menuText" = "Text";

"highlightedRange" = "Highlight Range";
Expand All @@ -77,6 +72,12 @@
"styleStrikethrough" = "Durchgestrichen";
"styleUnderlined" = "Unterstrichen";

"superscript" = "Grundlinie";
"superscriptIncrease" = "Øge";
"superscriptIncreaseDescription" = "Grundlinie vergrößern";
"superscriptDecrease" = "Mindske";
"superscriptDecreaseDescription" = "Grundlinie verkleinern";

"textAlignment" = "Tekstjustering";
"textAlignmentLeft" = "Linke Textausrichtung";
"textAlignmentRight" = "Rechte Textausrichtung";
Expand Down
35 changes: 18 additions & 17 deletions Sources/RichTextKit/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

"font" = "Font";
"fontSize" = "Font Size";
"fontSizeIncrease" = "Larger";
"fontSizeIncreaseDescription" = "Larger Text";
"fontSizeDecrease" = "Smaller";
"fontSizeDecreaseDescription" = "Smaller Text";

"color" = "Color";
"foregroundColor" = "Text Color";
Expand All @@ -23,44 +27,35 @@

"actionCopy" = "Copy";
"actionDismissKeyboard" = "Dismiss Keyboard";
"actionFontSizeIncrease" = "Larger Text";
"actionFontSizeDecrease" = "Smaller Text";
"actionIndentIncrease" = "Increase Indent";
"actionIndentDecrease" = "Decrease Indent";
"actionLineSpacingIncrease" = "Increase Line Spacing";
"actionLineSpacingDecrease" = "Decrease Line Spacing";
"actionPrint" = "Print";
"actionRedoLatestChange" = "Redo";
"actionSuperscriptIncrease" = "Increase Superscript";
"actionSuperscriptDecrease" = "Decrease Superscript";
"actionUndoLatestChange" = "Undo";

"fileFormatRtk" = "Rich Text Kit (.rtk)";
"fileFormatPdf" = "PDF (.pdf)";
"fileFormatRtf" = "Rich Text (.rtf)";
"fileFormatTxt" = "Plain Text (.txt)";

"indent" = "Indent";
"indentIncrease" = "Increase";
"indentIncreaseDescription" = "Increase Indent";
"indentDecrease" = "Decrease";
"indentDecreaseDescription" = "Decrease Indent";

"lineSpacing" = "Line Spacing";
"lineSpacingIncrease" = "Increase";
"lineSpacingIncreaseDescription" = "Increase Line Spacing";
"lineSpacingDecrease" = "Decrease";
"lineSpacingDecreaseDescription" = "Decrease Line Spacing";

"menuExport" = "Export";
"menuExportAs" = "Export as...";
"menuFont" = "Font";
"menuFontSizeIncrease" = "Larger";
"menuFontSizeDecrease" = "Smaller";
"menuFormat" = "Format";
"menuIndent" = "Indent";
"menuIndentIncrease" = "Increase";
"menuIndentDecrease" = "Decrease";
"menuPrint" = "Print...";
"menuSave" = "Save";
"menuSaveAs" = "Save as...";
"menuShare" = "Share";
"menuShareAs" = "Share as...";
"menuSuperscript" = "Superscript";
"menuSuperscriptIncrease" = "Increase";
"menuSuperscriptDecrease" = "Decrease";
"menuText" = "Text";

"highlightedRange" = "Highlight Range";
Expand All @@ -77,6 +72,12 @@
"styleStrikethrough" = "Strikethrough";
"styleUnderlined" = "Underline";

"superscript" = "Superscript";
"superscriptIncrease" = "Increase";
"superscriptIncreaseDescription" = "Increase Superscript";
"superscriptDecrease" = "Decrease";
"superscriptDecreaseDescription" = "Decrease Superscript";

"textAlignment" = "Text Alignment";
"textAlignmentLeft" = "Left";
"textAlignmentRight" = "Right";
Expand Down
Loading

0 comments on commit d9626b0

Please sign in to comment.