fastlane-old / snapshot

Automate taking localized screenshots of your iOS app on every device
https://fastlane.tools
1.96k stars 141 forks source link

Device locale not changed to match language #440

Closed stonehouse closed 8 years ago

stonehouse commented 8 years ago

I apologise in advance if I've missed something in the documentation, but I spent quite a lot of time trying to get localised screenshots working properly without success. Basically, the app changes language flawlessly, but the locale/language of the simulator doesn't match. This is mainly a problem because the app involves text entry. This means that, for example, German screenshots have red underlined text because its applying English validation.

I've tried several different combinations of configuration without luck, as well as manually setting the language in the simulator beforehand.

languages(["de-DE"])
languages(["de_DE"])
languages(["de"])
languages([["de", "de-DE"]])

I've additionally tried working with the launch arguments

launch_arguments(["-AppleLanguages (de)", "-AppleLocale de-DE"])

Any support would be greatly appreciated. Cheers

KrauseFx commented 8 years ago

Could you share your complete UI Test file?

stonehouse commented 8 years ago

Sure thing, I went ahead and created a new project to test the issue as a sanity check. If you look at the screenshot below you can see what I mean. All the codes there, let me know if I can help.

func testEnterText() {
        let text = "Test text entry in English. Jetzt Texteingabe auf Deutsch. Sacré bleu, Omelet du Fromage"

        let app = XCUIApplication()
        let inputTextView = app.textViews["Input"]
        inputTextView.tap()
        inputTextView.typeText(text)
        snapshot("Localization0")
    }
languages([
  "en-US",
  "de-DE",
  "fr-FR"
])

https://github.com/egosapien/SnapshotLocalizationProblem

https://github.com/egosapien/SnapshotLocalizationProblem/blob/master/fastlane/screenshots/de-DE/iPhone6-Localization0.png

vpolouchkine commented 8 years ago

I don't believe it's possible to set the language of the simulator (see https://github.com/fastlane/snapshot/issues/365#issuecomment-172638332). Perhaps you can work around it by disabling spelling corrections?

i2amsam commented 8 years ago

I wonder if the fix for https://github.com/fastlane/snapshot/pull/437 may also fix this. @egosapien could you try updating the SnapshotHelper.swift to replace the setLanguage with

    class func setLanguage(app: XCUIApplication) {
        let path = "/tmp/language.txt"

        do {
            let input = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String

            deviceLanguage = input
            locale = input

            app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))", "-AppleLocale", "\"\(locale)\"","-ui_testing"]
        } catch {
            print("Couldn't detect/set language...")
        }
    }
i2amsam commented 8 years ago

@egosapien could you try with the latest snapshot? I just released an updated version with https://github.com/fastlane/snapshot/pull/437 which improves locale and language handling.

stonehouse commented 8 years ago

@i2amsam I've just tried the latest version, and I have the same issue. As I mentioned in the beginning I also tried using the AppleLocale start parameter. It doesn't seem to make any difference to the simulator's locale. Or at least it has no effect on the keyboard.

My thought at the moment is to either write some debug only code to dismiss the keyboard and deactivate validation or add a UITest helper to change the keyboard. The latter is definitely preferable but I'm worried about how reliable it will be.

skywinder commented 8 years ago

same issue for me! :( langs doesn't changed..

skywinder commented 8 years ago

Hmm. It works for my first target, but doesn't work for another! I tried to remove all fastlane folder and init it for second project from the scratch, but still got this error. Please, let me know, if you need any additional details.

fastlane-bot commented 8 years ago

This issue was migrated to https://github.com/fastlane/fastlane/issues/1643. Please post all further comments there.

fastlane is now a mono repo, you can read more about the change in our blog post. All tools are now available in the fastlane main repo :rocket: