ui-screen-shooter icon indicating copy to clipboard operation
ui-screen-shooter copied to clipboard

Status bar is not set to the correct locale and region

Open ghost opened this issue 10 years ago • 10 comments

neither in the included sample project nor in my own project.

Xcode 5.1.1 with current iOS 7.1 SDK

ghost avatar Apr 12 '14 14:04 ghost

The language and locale are injected into the app when it is launched using the special command line parameters that affect NSUserDefaults. Apparently, it doesn't alter the simulator as a whole which is why the status bar isn't affected.

Do you have a suggestion for this? I'm inclined to just direct people to use an app like Status Magic (Mac app store link) because it makes it easy to set the status bar in screen shots to anything you want. I go through and change the status bar on screen shots that I use because I want to set the time anyway.

jonathanpenn avatar Apr 13 '14 14:04 jonathanpenn

I believe Status Magic has a code snippet on their site somewhere to make the status bar invisible for screenshots. This is vital for cases where there is blurred stuff behind the status bar. They also don’t have support for adding “100%” to the battery indicator, but they told me it will be in the next release.

ZevEisenberg avatar Apr 13 '14 14:04 ZevEisenberg

This also means that target.frontMostApp().preferencesValueForKey("AppleLanguages")[0]; won't return the correct language. Having this is important for navigating through localized content. I work on a podcast app, and want to select different podcasts for each language. The only solution I can think of at the moment is to make separate shoot_the_screens.js for each language and have the ui-screen-shotter.js call them.

PadraigK avatar May 07 '14 22:05 PadraigK

Ah, @PadraigK, that's an excellent point. Hmm. Well, I could re-introduce the script that hacked the user defaults plist file in the simulator directories. That forces the language at the simulator OS level, but it's a hack that I was never proud of. I'd rather make it an option that you could put in yourself than the default.

Thoughts?

jonathanpenn avatar May 08 '14 00:05 jonathanpenn

I went ahead with making separate shoot-en_US.js, shoot-fr-FR.js etc.. files and it works ok. Probably better to go this way and not have to rely on hacking the plist file as before. Maybe someone clever can come up with another way to pull the language from the simulator. We could also file a Radar pointing out that the value of the locale, etc.. are reported incorrectly in this case.

PadraigK avatar May 08 '14 00:05 PadraigK

Please confirm still broken in XCode 6

fulldecent avatar Sep 24 '14 15:09 fulldecent

Does UI Screen Shooter work when running on-device? The reason I ask is that in Yosemite, when you enable screen recording on an iOS 8 device through QuickTime Player, it magically turns the status bar into an App Store-perfect status bar, with 9:41 AM and all the rest. If Apple fixes this bug with using AppleScript to set an iOS device as the input source, this could potentially be put into your scripts.

ZevEisenberg avatar Sep 24 '14 15:09 ZevEisenberg

I ended up with a similar workaround to @PadraigK : I have JS files with variable declarations automation-variables-en.js and cat this file and the actual logic in my config-automation.js to one JS script before each run, altering _run_automation like so:

function _run_automation {
    # Runs the UI Automation JavaScript file that actually takes the screenshots.

    automation_base="$1"
    language="$2"
    simulator="$3"

    automation_script="$UISS_DIR"/automation-full.js
    lang_vars="$UISS_DIR"/automation-variables-en.js
    if [ -f "$UISS_DIR"/automation-variables-${language}.js ]; then
        lang_vars="$UISS_DIR"/automation-variables-${language}.js
    fi
    cat "$lang_vars" "$automation_base" > "$automation_script"

    ...

    rm "$automation_script"
}

p2 avatar Oct 06 '14 16:10 p2

My solution was to export a language environment variable in ui-screen-shooter.sh:

for simulator in "${simulators[@]}"; do
  for language in $languages; do
    export UISS_LANG="$language"
    ...

and then pull this into my automation script like this and use it to change units etc. based on the locale:

var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["UISS_LANG"], 5);
var language = result.stdout.substring(0,result.stdout.length-1);
UIALogger.logMessage("language = " + language);
var usa = (language == "en-US");
var uk  = (language == "en-GB");
...

bmcpherson avatar Oct 26 '14 09:10 bmcpherson

I use NSLocaleUsesMetricSystem to successfully get whether I should display US or SI units. The simulator gets and displays correct units per language. But [[NSLocale preferredLanguages] firstObject] always returns English. Am I doing something wrong or is this related to this issue? It sounds to me that the plist hack is the only solution that will work for my purposes.

Update: Yes, I was doing something wrong. Never mind! It works great!

Yosemite (10.10.1) + Xcode 6.1

twestley avatar Nov 21 '14 22:11 twestley