Skip to content

Commit

Permalink
MAM-3995-change-language-via-settings (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnolens authored Mar 4, 2024
1 parent c6902dd commit 38df632
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Mammoth.xcodeproj/xcshareddata/xcschemes/Mastodon.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
</EnvironmentVariable>
</EnvironmentVariables>
<StoreKitConfigurationFileReference
identifier = "../../Mastodon/IAPConfig.storekit">
identifier = "../../Mammoth/IAPConfig.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
Expand Down
77 changes: 75 additions & 2 deletions Mammoth/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3594,8 +3594,8 @@
},
"nl" : {
"stringUnit" : {
"state" : "new",
"value" : "Discover"
"state" : "translated",
"value" : "Ontdek"
}
},
"pt" : {
Expand Down Expand Up @@ -5475,6 +5475,79 @@
}
}
},
"settings.appearance.language" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Language"
}
},
"nl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Taal"
}
}
}
},
"settings.appearance.language.alert.cancel" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annuleer"
}
}
}
},
"settings.appearance.language.alert.cta" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Continue"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ga verder"
}
}
}
},
"settings.appearance.language.alert.description" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "There are different steps to change your Mammoth app language.\n\n1. Continue to the next screen.\n2. Tap Language to select the language that you want.\n\nIf no language setting is available, go to your general device language settings to first set a preferred language."
}
}
}
},
"settings.appearance.language.alert.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "How to set your app language"
}
}
}
},
"settings.appearance.light" : {
"localizations" : {
"en" : {
Expand Down
32 changes: 30 additions & 2 deletions Mammoth/Screens/Settings/AppearanceSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class AppearanceSettingsViewController: UIViewController, UITableViewDataSource,
AppearanceOptions.contentWarning,
AppearanceOptions.sensitiveContent,
AppearanceOptions.autoplay,
AppearanceOptions.translation
AppearanceOptions.translation,
AppearanceOptions.language,
]
return allItems.compactMap({$0})
}
Expand All @@ -47,6 +48,7 @@ class AppearanceSettingsViewController: UIViewController, UITableViewDataSource,
case sensitiveContent
case autoplay
case translation
case language

@available(*, unavailable)
case all
Expand Down Expand Up @@ -593,7 +595,6 @@ class AppearanceSettingsViewController: UIViewController, UITableViewDataSource,
case AppearanceOptions.translation:
let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)
cell.textLabel?.text = NSLocalizedString("settings.appearance.translationLang", comment: "")
cell.imageView?.image = UIImage(systemName: "globe")
cell.imageView?.image = settingsFontAwesomeImage("\u{f0ac}")
cell.accessoryView = nil
cell.accessoryType = .disclosureIndicator
Expand All @@ -602,6 +603,18 @@ class AppearanceSettingsViewController: UIViewController, UITableViewDataSource,
cell.focusEffect = UIFocusHaloEffect()
}
return cell

case AppearanceOptions.language:
let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)
cell.textLabel?.text = NSLocalizedString("settings.appearance.language", comment: "")
cell.imageView?.image = settingsFontAwesomeImage("\u{f1ab}")
cell.accessoryView = nil
cell.accessoryType = .disclosureIndicator
cell.backgroundColor = .custom.OVRLYSoftContrast
if #available(iOS 15.0, *) {
cell.focusEffect = UIFocusHaloEffect()
}
return cell
}

default: return UITableViewCell()
Expand All @@ -617,6 +630,21 @@ class AppearanceSettingsViewController: UIViewController, UITableViewDataSource,
let vc = TranslationSettingsViewController()
navigationController?.pushViewController(vc, animated: true)
}

if AppearanceOptions.allCases[indexPath.row] == AppearanceOptions.language {
let alert = UIAlertController(title: NSLocalizedString("settings.appearance.language.alert.title", comment: "Alert title when tapping on the language setting item"), message: NSLocalizedString("settings.appearance.language.alert.description", comment: "Alert description when tapping on the language setting item"), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("settings.appearance.language.alert.cta", comment: "Alert call-to-action when tapping on the language setting item"), style: .default, handler: { _ in
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { _ in })
}
}))
alert.addAction(UIAlertAction(title: NSLocalizedString("settings.appearance.language.alert.cancel", comment: "Alert cancel button when tapping on the language setting item"), style: .cancel, handler: nil))
getTopMostViewController()?.present(alert, animated: true)
}
default:
break
}
Expand Down

0 comments on commit 38df632

Please sign in to comment.