1 Reply
      Latest reply on Feb 10, 2019 2:58 PM by Claude31
      attiliopiccolo Level 1 Level 1 (0 points)

        I have a problem with my app internazionalization.

        I put another lenguage with .string method, I transale it and the app work well, everithings is tramslate but not the sctring of code that I put in

        override func viewDidLoad() {

                super.viewDidLoad()

        // Do any additional setup after loading the view.

        Info_TextView.layer.cornerRadius = 5    

        Info_TextView.text = "Test String"

        }

         

        So I try for this string to use the NSLocalizedString:

         

        override func viewDidLoad() {

                super.viewDidLoad()

         

                // Do any additional setup after loading the view.

                Info_TextView.layer.cornerRadius = 5

               Info_TextView.text = NSLocalizedString("Test String", comment: "")

              }

         

        and after I put the translate in main.string (localized file)

         

        "Test String" = "Testo di Prova"

         

        Unfortunally this don't work.

         

        Thank you for your time

        • Re: Problem with NSLocalizedString
          Claude31 Level 8 Level 8 (5,645 points)

          You should put this translation in localizable.strings (italian) file, not in the main.strings (italian).

          "Test String" = "Testo di Prova";

          Note: don't forget ; at the end of each line in .strings files

           

          The format in main.strings is like

          "h9C-NM-iCa.text" = "Testo di Prova";

           

          where h9C-NM-iCa is the ID of the object in IB that you see in Identy Inspector (3rd icon with square shape of Inspector panel)

           

          You should also adopt the naming conventions of Swift (camelCase).

          For instance, Info_TextView is a var ;

          So, it should start with lowercase, and not include underscore

          So, writes as

          infoTextView