Search code examples
swiftxcodelocalizationfirebaseui

Localizing FirebaseUI Auth


I am a swift newbie so please bear with me. I have successfully integrated FirebaseUI into my app. I now wish to localize the strings for Dutch. My whole project is in Dutch so I do not have any localization in the project since it is all hard coded in the storyboard. The FirebaseUI docs say that you should:

// Swift
authUI?.customStringsBundle = NSBundle.mainBundle() // Or any custom bundle.

But I am not sure where to actually place the strings file in the project (or how) or if I should be using a custom bundle?

I have spent a whole day playing around with bundles but without success. Your help would be appreciated!


Solution

  • Here is how I got it to work eventually:

    1. Add a strings file called FirebaseAuthUI.strings. I copied the content of this file from here
    2. Use the following code when you create the controller to handle sign in:

    Code:

    if let bundlePath = Bundle.main.path(forResource: "FirebaseAuthUI", ofType: "strings") {
        let bundle = Bundle(path: bundlePath)
        authUI?.customStringsBundle = bundle;
    }
    

    Don't forget to translate the strings in step 1.

    Good luck