Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: RTL localization for assets and strings #441

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"images" : [
{
"filename" : "arrowRight16.svg",
"idiom" : "universal"
"idiom" : "universal",
"language-direction" : "left-to-right"
}
],
"info" : {
Expand Down
17 changes: 17 additions & 0 deletions Core/Core/Domain/Model/CourseDates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,23 @@ public enum CompletionStatus: String {
case thisWeek = "This Week"
case nextWeek = "Next Week"
case upcoming = "Upcoming"

public var localized: String {
switch self {
case .completed:
return CoreLocalization.CourseDates.completed
case .pastDue:
return CoreLocalization.CourseDates.pastDue
case .today:
return CoreLocalization.CourseDates.today
case .thisWeek:
return CoreLocalization.CourseDates.thisWeek
case .nextWeek:
return CoreLocalization.CourseDates.nextWeek
case .upcoming:
return CoreLocalization.CourseDates.upcoming
}
}
}

public extension Array {
Expand Down
12 changes: 12 additions & 0 deletions Core/Core/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ public enum CoreLocalization {
}
}
public enum CourseDates {
/// Completed
public static let completed = CoreLocalization.tr("Localizable", "COURSE_DATES.COMPLETED", fallback: "Completed")
/// Next week
public static let nextWeek = CoreLocalization.tr("Localizable", "COURSE_DATES.NEXT_WEEK", fallback: "Next week")
/// Past due
public static let pastDue = CoreLocalization.tr("Localizable", "COURSE_DATES.PAST_DUE", fallback: "Past due")
/// This week
public static let thisWeek = CoreLocalization.tr("Localizable", "COURSE_DATES.THIS_WEEK", fallback: "This week")
/// Today
public static let today = CoreLocalization.tr("Localizable", "COURSE_DATES.TODAY", fallback: "Today")
/// Upcoming
public static let upcoming = CoreLocalization.tr("Localizable", "COURSE_DATES.UPCOMING", fallback: "Upcoming")
public enum ResetDate {
/// Your dates could not be shifted. Please try again.
public static let errorMessage = CoreLocalization.tr("Localizable", "COURSE_DATES.RESET_DATE.ERROR_MESSAGE", fallback: "Your dates could not be shifted. Please try again.")
Expand Down
1 change: 1 addition & 0 deletions Core/Core/View/Base/CourseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct CourseButton: View {
.foregroundColor(Theme.Colors.textPrimary)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
.padding(.vertical, 8)
.foregroundColor(Theme.Colors.accentXColor)
}
Expand Down
7 changes: 7 additions & 0 deletions Core/Core/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,10 @@
"COURSE_DATES.RESET_DATE.ERROR_MESSAGE" = "Your dates could not be shifted. Please try again.";
"COURSE_DATES.RESET_DATE.SUCCESS_MESSAGE" = "Your dates have been successfully shifted.";
"COURSE_DATES.RESET_DATE.TITLE" = "Course Dates";

"COURSE_DATES.TODAY" = "Today";
"COURSE_DATES.COMPLETED" = "Completed";
"COURSE_DATES.PAST_DUE" = "Past due";
"COURSE_DATES.THIS_WEEK" = "This week";
"COURSE_DATES.NEXT_WEEK" = "Next week";
"COURSE_DATES.UPCOMING" = "Upcoming";
5 changes: 4 additions & 1 deletion Course/Course/Presentation/Dates/CourseDatesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ struct CompletedBlocks: View {
}) {
HStack {
VStack(alignment: .leading) {
Text(CompletionStatus.completed.rawValue)
Text(CompletionStatus.completed.localized)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)

Expand Down Expand Up @@ -289,6 +289,8 @@ struct CompletedBlocks: View {
if block.canShowLink && !block.firstComponentBlockID.isEmpty {
Image(systemName: "chevron.right")
.resizable()
.flipsForRightToLeftLayoutDirection(true)

Comment on lines +292 to +293
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra line here.

.scaledToFit()
.frame(width: 6.55, height: 11.15)
.labelStyle(.iconOnly)
Expand Down Expand Up @@ -328,6 +330,7 @@ struct BlockStatusView: View {
if block.canShowLink && !block.firstComponentBlockID.isEmpty {
Image(systemName: "chevron.right")
.resizable()
.flipsForRightToLeftLayoutDirection(true)
.scaledToFit()
.frame(width: 6.55, height: 11.15)
.labelStyle(.iconOnly)
Expand Down
4 changes: 3 additions & 1 deletion Course/Course/Presentation/Handouts/HandoutsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ struct HandoutsItemCell: View {
.font(Theme.Fonts.labelSmall)
}
Spacer()
Image(systemName: "chevron.right").resizable()
Image(systemName: "chevron.right")
.resizable()
.flipsForRightToLeftLayoutDirection(true)
.frame(width: 7, height: 12)
.foregroundColor(Theme.Colors.accentColor)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public struct CourseVerticalView: View {
}
}
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
.padding(.vertical, 8)
}
.padding(.horizontal, 36)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public struct TopicCell: View {
.multilineTextAlignment(.leading)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
.foregroundColor(Theme.Colors.accentColor)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ struct ProfileSupportInfoView: View {
.foregroundColor(Theme.Colors.textPrimary)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
}
}
.simultaneousGesture(TapGesture().onEnded {
Expand Down Expand Up @@ -187,6 +188,7 @@ struct ProfileSupportInfoView: View {
.font(Theme.Fonts.titleMedium)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
}
}
.foregroundColor(.primary)
Expand Down
2 changes: 2 additions & 0 deletions Profile/Profile/Presentation/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public struct SettingsView: View {
.font(Theme.Fonts.titleMedium)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
}
})
.accessibilityIdentifier("video_settings_button")
Expand Down Expand Up @@ -183,6 +184,7 @@ public struct SettingsView: View {
.font(Theme.Fonts.titleMedium)
Spacer()
Image(systemName: "chevron.right")
.flipsForRightToLeftLayoutDirection(true)
}
})
.accessibilityIdentifier("video_settings_button")
Expand Down
Loading