From e856605a0991a6156c9c821765c89fcf10fcbe4d Mon Sep 17 00:00:00 2001 From: daboe01 Date: Thu, 28 May 2026 17:38:14 +0200 Subject: [PATCH] _CPRuleEditorViewSliceRow integration --- AppKit/CPRuleEditor/CPRuleEditor.j | 26 +++++++++++++++---- .../CPRuleEditor/_CPRuleEditorViewSliceRow.j | 22 ++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/AppKit/CPRuleEditor/CPRuleEditor.j b/AppKit/CPRuleEditor/CPRuleEditor.j index 1910d6153..b1f30dc30 100644 --- a/AppKit/CPRuleEditor/CPRuleEditor.j +++ b/AppKit/CPRuleEditor/CPRuleEditor.j @@ -127,7 +127,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", BOOL _isKeyDown; BOOL _nestingModeDidChange; - _CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer); + _CPRuleEditorLocalizer _standardLocalizer; CPDictionary _itemsAndValuesToAddForRowType; } @@ -384,7 +384,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", */ - (CPDictionary)formattingDictionary { - return [_standardLocalizer dictionary]; + return [[self standardLocalizer] dictionary]; } /*! @@ -396,6 +396,9 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", */ - (void)setFormattingDictionary:(CPDictionary)dictionary { + if (_standardLocalizer == nil) + _standardLocalizer = [_CPRuleEditorLocalizer new]; + [_standardLocalizer setDictionary:dictionary]; _stringsFilename = nil; } @@ -440,6 +443,19 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", } } +- (_CPRuleEditorLocalizer)standardLocalizer +{ + if (_standardLocalizer == nil) + _standardLocalizer = [_CPRuleEditorLocalizer new]; + + return _standardLocalizer; +} + +- (void)setStandardLocalizer:(_CPRuleEditorLocalizer)aLocalizer +{ + _standardLocalizer = aLocalizer; +} + /*! @name Providing Data */ @@ -1924,17 +1940,17 @@ TODO: implement - (CPString)_toolTipForAddCompoundRowButton { - return [_standardLocalizer localizedStringForString:@"Add compound row"]; + return [[self standardLocalizer] localizedStringForString:@"Add compound row"]; } - (CPString)_toolTipForAddSimpleRowButton { - return [_standardLocalizer localizedStringForString:@"Add row"]; + return [[self standardLocalizer] localizedStringForString:@"Add row"]; } - (CPString)_toolTipForDeleteRowButton { - return [_standardLocalizer localizedStringForString:@"Delete row"]; + return [[self standardLocalizer] localizedStringForString:@"Delete row"]; } - (void)_updateSliceIndentations diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j index 8866095d4..181f935ba 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j @@ -334,6 +334,28 @@ [_correspondingRuleItems setArray:ruleItems]; + // Localize drop-down options in context and reorder/insert intermediate labels natively + var localizer = [_ruleEditor standardLocalizer]; + if (localizer) + { + [localizer localizeMenuItemsForViews:_ruleOptionViews]; + _ruleOptionViews = [localizer localizeAndReorderViews:_ruleOptionViews]; + } + + // Rebuild frame configurations to match the new localized layout order + [_ruleOptionFrames removeAllObjects]; + [_ruleOptionInitialViewFrames removeAllObjects]; + + var newCount = [_ruleOptionViews count]; + for (var i = 0; i < newCount; i++) + { + var view = [_ruleOptionViews objectAtIndex:i], + frame = [view frame]; + + [_ruleOptionFrames addObject:frame]; + [_ruleOptionInitialViewFrames addObject:frame]; + } + if (!_editable) [self _updateEnabledStateForSubviews];