fastlane-old / snapshot

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

Language codes are too naive #422

Closed ahknight closed 8 years ago

ahknight commented 8 years ago

The language code parser in the helper is presuming "XX_XX" for the codes, but this is incorrect. For instance, to use French Canadian in Canada I would say "fr-CA_CA". This breaks the tool rather horribly.

I wound up hacking the helper as follows. It could use more love (and error checking) but you get the idea:

    let input = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
    var components : Array<String> = input.componentsSeparatedByString("_")
    let deviceLanguage = components[0]
    let locale = components[1]
    app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))", "-AppleLocale", "\"\(locale)\"","-ui_testing"]
ahknight commented 8 years ago

This is also what is breaking the Korean and Chinese users, by the way.

b-ray commented 8 years ago

I'm having the same problem. Using zh-Hans (chinese simplified) or zh-Hant (chinese traditional) results in the same language zh being used with the current version of the SnapshotHelper.swift. I ended up adding a check for those two languages, and using the whole language-string as the deviceLanguage: (at SnapshotHelper.swift around line 42)

deviceLanguage = locale.substringToIndex(locale.startIndex.advancedBy(2, limit:locale.endIndex))
if locale == "zh-Hans" || locale == "zh-Hant" {
    deviceLanguage = locale
}

That, of course, is not an optimal solution. I'd also suggest to change the language-code-format as proposed by @ahknight, for a better handling of locale and language.

i2amsam commented 8 years ago

@ahknight @b-ray I just merged https://github.com/fastlane/snapshot/pull/437 (from @bartoszj, thanks!!) which improves language handling, could you try again?

b-ray commented 8 years ago

Thanks @ahknight and @bartoszj, my issue is resolved, it works perfectly now :-)

i2amsam commented 8 years ago

Huzzah! 🚀🎉

fastlanebot commented 8 years ago

This issue was migrated to https://github.com/fastlane/fastlane/issues/2497. 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: