Localize-Swift icon indicating copy to clipboard operation
Localize-Swift copied to clipboard

Does not work in UITests

Open maa-x opened this issue 8 years ago • 3 comments

Having tried all day, I cannot get Localize-Swift to work in UITests. Apparently this could have something to do with the wrong bundle being used.

(lldb) po NSLocalizedString("PASSWORD", comment: "")
"PASSWORD"

(lldb) po NSLocalizedString("PASSWORD", bundle: NSBundle(path: NSBundle(forClass: CaribooUITests.self).pathForResource("en", ofType: "lproj")!)!, comment: "")
"Password"

(lldb) po "PASSWORD".localized()
"PASSWORD"

I have no idea how to implement this and would appreciate help !

maa-x avatar May 12 '16 16:05 maa-x

Hey @SASDOE, you are on the right path... Localise-Swift is looking for the mainBundle (always) and that doesn't work from the the test bundle. I'll try and find a good fix for this...

marmelroy avatar May 12 '16 21:05 marmelroy

Cheers. I'd love to give a helping hand but I know nothing about localization and haven't been able to find a way for this to work in a retro compatible fashion. I've been told the Base bundle is just a random container in the UITests, not sure if that helps.

Tell me if you find a solution and need help writing it up.

maa-x avatar May 13 '16 12:05 maa-x

@marmelroy What you thing about use the same approach used at: Swifternalization?

  • Turning your library settings possible with a singleton;
  • Localize.configure(bundle) // if files are in another bundle

RafaelPlantard avatar Jul 13 '16 21:07 RafaelPlantard