Language codes are too naive
ahknight opened this issue ยท 6 comments
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"]
This is also what is breaking the Korean and Chinese users, by the way.
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.
Huzzah! ๐๐
This issue was migrated to fastlane/fastlane#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 ๐