Skip to content

Releases: devMfawzy/RTLKit

Release list

1.0.0

Choose a tag to compare

@devMfawzy devMfawzy released this 10 Sep 19:05

First Release.

RTLKit keeps numbers, dates, and phone numbers reading correctly when they sit inside Arabic or Hebrew text. "0 / 12" has no direction of its own, so in a right-to-left paragraph it renders as 12 / 0. RTLKit wraps it in Unicode isolates (UAX #9) so the fragment resolves on its own without disturbing the text around it.

Text("التقدم: \(done) / \(total)")            // التقدم: 12 / 0
Text("التقدم: \(rtlSafe: "\(done) / \(total)")")  // التقدم: 0 / 12

What's in it

  • rtlSafe on String, and a \(rtlSafe:) interpolation for values inside a
    larger string.
  • isDirectionallyNeutral, firstStrongDirection and isBidirectional for
    working out why one string flips and another doesn't.
  • convertingNumerals(to:) and convertingNumerals(for:) for Western,
    Arabic-Indic and Eastern Arabic-Indic digits, following regional convention —
    Egypt and the Gulf use ٠١٢, Morocco and Algeria use 012.
  • strippingDirectionalControls() for storing and comparing text that was
    isolated for display.
  • Text(rtlSafe:) in RTLKitUI.

Install

.package(url: "https://github.com/devMfawzy/RTLKit.git", from: "1.0.0")
pod 'RTLKit'          # string API
pod 'RTLKit/UI'       # plus SwiftUI helpers

RTLKit depends on Foundation alone. iOS 13+, macOS 10.15+, tvOS 13+,
watchOS 6+, visionOS 1+ through SPM; iOS and macOS through CocoaPods.

30 tests, and a demo app under Example/.