Post

Replies

Boosts

Views

Activity

Reply to Tab bar item localization
The extension of string is like so: extension String {   func localize() - String {     return NSLocalizedString(       self,       tableName: "Localizable",       bundle: .main,       value: self,       comment: self)   }       public func localize(with arguments: [CVarArg]) - String {     return String(format: self.localize(), locale: nil, arguments: arguments)   } } Most of my localisation is in Localizable.strings and hoped I could localize from there. But as you said, I might as well create Main.strings files and do the localization in there for those titles. I wanted to avoid creating other files, but it really isn't a problem in the end.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to Tab bar item localization
class LevelsViewController: UIViewController {  override func viewDidLoad() {     super.viewDidLoad() tabBarItem.title = "LevelsVC-TabBarItem".localize() } } Here is an example. LevelsViewController is a view controller that is displayed when tapping a tab bar item.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to Tab bar item localization
2 titans, and now a god :) This forum is underrated. Thanks for your suggestions Developer Tools Engineer. You are very right, I got myself into maintaining my own Localizable.strings file with commenting each line in there. Fortunately the project is not too big, but for the next one, I will certainly do it the right way from the start.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to What is the earliest method to put in and trigger a performSegue?
Sure. VC1 is entry of app. I only need that in the stack so I can unwind later to it VC1 only action is the performeSegue to VC2. VC2 is the main controller of app with lots of work and variables alive. When a user logs out of the app, I need all states to be destroyed. I found the simplest way, instead of setting each variable to default when the user logs out, is to unwind to VC1 (so VC2 is destroyed) then VC1 immediately loads VC2, fresh, with all variables on their default values. So the goal is to perform segue to VC2 from VC1 as fast as possible so users don't even see VC1. That may not be the most legit way to achieve this, but the unwind makes absolutely certain that all states of VC2 die.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How to best handle this localization scenario?
Thank you very much for your answer. That seems a smart way to resolve the problem. I will test this solution over the next few days, and will not forget to come back and close the thread if all is fine
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How to best handle this localization scenario?
Thanks for the second solution. I'm giving it a go. I'll create the localizedStrings once for all on app initialization, then create a string extension "ToBaseLang" to handle all the rest.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Localization not loading in some cases
It appears to be because my population of the ui text was in viewDidLoad, which doesn't run each time the view controller is modally presented. It works if I put the ui population code in viewDidAppear, but is it the best place to put it?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Localization not loading in some cases
viewWillAppear worked best thanks.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Tab bar item localization
I haven't created a Main.strings. Is there anyway to translate those tab bar title without Main.strings?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Tab bar item localization
The extension of string is like so: extension String {   func localize() - String {     return NSLocalizedString(       self,       tableName: "Localizable",       bundle: .main,       value: self,       comment: self)   }       public func localize(with arguments: [CVarArg]) - String {     return String(format: self.localize(), locale: nil, arguments: arguments)   } } Most of my localisation is in Localizable.strings and hoped I could localize from there. But as you said, I might as well create Main.strings files and do the localization in there for those titles. I wanted to avoid creating other files, but it really isn't a problem in the end.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Tab bar item localization
class LevelsViewController: UIViewController {  override func viewDidLoad() {     super.viewDidLoad() tabBarItem.title = "LevelsVC-TabBarItem".localize() } } Here is an example. LevelsViewController is a view controller that is displayed when tapping a tab bar item.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Tab bar item localization
Answers from the titans. Thank you for both your answers. I went ahead with awakeFromNib().
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Tab bar item localization
2 titans, and now a god :) This forum is underrated. Thanks for your suggestions Developer Tools Engineer. You are very right, I got myself into maintaining my own Localizable.strings file with commenting each line in there. Fortunately the project is not too big, but for the next one, I will certainly do it the right way from the start.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to What is the earliest method to put in and trigger a performSegue?
Sure. VC1 is entry of app. I only need that in the stack so I can unwind later to it VC1 only action is the performeSegue to VC2. VC2 is the main controller of app with lots of work and variables alive. When a user logs out of the app, I need all states to be destroyed. I found the simplest way, instead of setting each variable to default when the user logs out, is to unwind to VC1 (so VC2 is destroyed) then VC1 immediately loads VC2, fresh, with all variables on their default values. So the goal is to perform segue to VC2 from VC1 as fast as possible so users don't even see VC1. That may not be the most legit way to achieve this, but the unwind makes absolutely certain that all states of VC2 die.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Subclassing UIButton doesn't change font size
Thank you for testing. You are right, it has to do with font as with Helvetica it works. This is in my case in simulator iPhone 8, iOS 13.2.2 Maybe It's not the proper font label. As i'm sure this device/os has this font. I will investigate spelling.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Subclassing UIButton doesn't change font size
Indeed, definitely a bad font name. Thank you, you saved me a lot of time.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to iOS 15 cannot pop up App Tracking Transparency authorization UI
From my experience, it does popup, but not if you ask it to popup immediately at app start.... I have it popup when user get BACK to home screen and not anymore upon app launch. It's as if there is a delay upon app start that prevents it to popup. Anyone has clarifications on this?
Replies
Boosts
Views
Activity
Sep ’21