none
Bing Maps SDK and user language changes at runtime (HTML/JS, Windows 8.0 SDK) RRS feed

  • Question

  • We're working on globalizing our app for use outside the US. One of the recommendations in the Windows 8 (and 8.1) Application Resources SDK app sample is to handle on-the-fly changes to the user's language. This is done using the oncontextchanged event on the WinJS.Resources namespace.

    However, loading our map instance appears to override the user's language for our entire app, such that oncontextchanged no longer fires. In effect, once the Bing Maps instance has been loaded, changes to the user language (via the PC settings / control panel) have no effect.

    Could the Bing Maps SDK be overriding Windows.ApplicationModel.Resources.Core.ResourceManager.current.defaultContext (specifically, the languages property)? I ask because invoking Windows.ApplicationModel.Resources.Core.ResourceManager.current.defaultContext.reset() (after the map is loaded) seems to restore the desired functionality---at least 'til the map is loaded again.

    Relatedly(?), once the map has been loaded, re-initializing it with a different culture doesn't seem to have any effect (in terms of showing a localized version). Whatever culture/language was set when the map was first initialized persists (and the map again overrides the user's context with this language, every time it is loaded). Is this the expected behavior? Is there a recommended workaround?

    Wednesday, July 17, 2013 3:03 PM

Answers

  • The map automatically uses the language that the PC is set to. If you specify a language when loading the map you will override this default functionality and basically hardcode the map to use the language you specified. For most global apps you will not want to specify the culture on the map as it will already change automatically based on the settings on the end users computer.

    http://rbrundritt.wordpress.com

    Wednesday, July 17, 2013 3:28 PM
  • If the map is already loaded then the language won't change. The language of the map can only be set when the map is initially loaded. If the language changes, and you need the map on the already running app to change as well then you would need to dispose the map and reload it. This seems like a very odd use case. I haven't come across anyone developing for this type of situations. Not even my customers who run their apps 24/7 without reloading.

    http://rbrundritt.wordpress.com

    Wednesday, July 17, 2013 4:16 PM
  • Disposing the map would get rid of it. You would then need to reload it. If you wanted to you could also detect the current language and specify it in the map when loading it.

    http://rbrundritt.wordpress.com

    Thursday, July 18, 2013 3:24 PM

All replies

  • The map automatically uses the language that the PC is set to. If you specify a language when loading the map you will override this default functionality and basically hardcode the map to use the language you specified. For most global apps you will not want to specify the culture on the map as it will already change automatically based on the settings on the end users computer.

    http://rbrundritt.wordpress.com

    Wednesday, July 17, 2013 3:28 PM
  • Thanks for the quick reply, Ricky!

    As you note, leaving the language unspecified does pick up the user's current settings. Unfortunately, this still seems to "hardcode" the map to use only one language--in this case, whatever language was set as primary when the map was loaded.

    Changing the language after this point appears to have no effect on the map's localization---and every reinitialization of the map after this point effectively overrides newer changes to the user's language preference .

    Wednesday, July 17, 2013 4:11 PM
  • If the map is already loaded then the language won't change. The language of the map can only be set when the map is initially loaded. If the language changes, and you need the map on the already running app to change as well then you would need to dispose the map and reload it. This seems like a very odd use case. I haven't come across anyone developing for this type of situations. Not even my customers who run their apps 24/7 without reloading.

    http://rbrundritt.wordpress.com

    Wednesday, July 17, 2013 4:16 PM
  • Hmm... unless I'm going crazy, running map.dispose() doesn't seem to help here.

    As for use cases, it's true; this is unlikely to affect many of our users. But if a user were to change her language while the app is running, it could be fairly confusing (particularly since the map overrides changes for the entire app, not just for the map).

    Wednesday, July 17, 2013 4:34 PM
  • Disposing the map would get rid of it. You would then need to reload it. If you wanted to you could also detect the current language and specify it in the map when loading it.

    http://rbrundritt.wordpress.com

    Thursday, July 18, 2013 3:24 PM