Namespaces
Variants
Actions
(Difference between revisions)

HERE Maps API - Setting the language

Jump to: navigation, search
(Avnee.nathani - - Summary: updated link)
m (Jasfox - update to 2.2.4)
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]]
+
[[Category:Nokia Maps]][[Category:Code Snippet]][[Category:JavaScript]]
 
{{Abstract|This article explains how to set the map interface language and how to display more language information }}
 
{{Abstract|This article explains how to set the map interface language and how to display more language information }}
  
 +
 +
 +
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= Web browser
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies=Nokia Maps 2.2.4
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= Nokia Maps, JavaScript, language
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by=[[User:avnee.nathani]]
 +
|update-timestamp=20111231
 +
|creationdate=20110628
 +
|author=[[User:Maveric]]
 +
}}
 +
 +
{{SeeAlso|
 +
*  [http://developer.here.net/javascript_api Nokia Maps API]
 +
*  [http://www.developer.nokia.com/Community/Wiki/Nokia_Maps_API_-_getting_and_setting_the_default_language_in_application_context Getting and Setting the Default Language]
 +
* [http://developer.here.net/apiexplorer/examples/api-for-js/map/map-change-language.html Changing the language of the map]
 +
}}
 
== Setting the map interface language ==
 
== Setting the map interface language ==
  
 
To set the language, use the following:
 
To set the language, use the following:
  
<code java>
+
<code javascript>
ovi.mapsapi.packages.load("language", "de-DE");
+
nokia.Settings.set("defaultLanguage","de-DE");
 
</code>
 
</code>
  
For the language, define it in format of ISO3166-1 alpha-2 country code, e.g. "en-US", "de-DE" and so on.
+
For the language, define it in format of ISO3166-1 alpha-2 country code, e.g. {{Icode|en-US}}, {{Icode|de-DE}} and so on.
  
 
== Getting more language information ==
 
== Getting more language information ==
  
When you want to display more information, use the class ovi.mapsapi.language.Info.
+
When you want to display more information, use the class {{Icode|nokia.maps.language.Info}}.
  
It has a method called "getDefinition (code, [definitions]) : Object".
+
It has a method called {{Icode|getDefinition (code, [definitions]) : Object}}.
  
This will retrieve the language meta data for a given LCID. The lookup will be done in two steps:  
+
This will retrieve the language meta data for a given LCID. The look up will be done in two steps:  
 
First the full LCID (ISO-639-1 AND ISO-3166-1 alpha-2) will be matched. If the full LCID cannot be found  
 
First the full LCID (ISO-639-1 AND ISO-3166-1 alpha-2) will be matched. If the full LCID cannot be found  
 
the more general form (ISO-639-1 only) will be matched.
 
the more general form (ISO-639-1 only) will be matched.
  
An example of using the getDefinition:
+
An example of using the {{Icode|getDefinition()}} method:
  
<code java>
+
<code javascript>
>>> mylanguage = ovi.mapsapi.language.Info;
+
    mylanguage = nokia.maps.language.Info;
 
</code>
 
</code>
  
 
Would return:
 
Would return:
<code java>
+
<code javascript>
 
Object { definitions={...}, translations={...}, more...}
 
Object { definitions={...}, translations={...}, more...}
 
</code>
 
</code>
Line 35: Line 66:
 
then...
 
then...
  
<code java>
+
<code javascript>
>>> mylanguage.getDefinition("de-DE");
+
  mylanguage.getDefinition("de-DE");
 
</code>
 
</code>
  
 
would return e.g:
 
would return e.g:
  
<code java>
+
<code javascript>
 
Object { key="de", iso639_1="de", more...}
 
Object { key="de", iso639_1="de", more...}
 
</code>
 
</code>
Line 47: Line 78:
 
== Summary ==
 
== Summary ==
  
Please check out the chapter http://api.maps.nokia.com/2.1.0/apireference/symbols/nokia.maps.language.html for more information on languages.
+
Please check out the chapter http://developer.here.net/docs/maps_js/topics/language-support.html for more information on languages.

Revision as of 14:35, 14 March 2013

This article explains how to set the map interface language and how to display more language information


Article Metadata

Compatibility
Platform(s): Web browser
Dependencies: Nokia Maps 2.2.4

Article
Keywords: Nokia Maps, JavaScript, language
Created: Maveric (28 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (14 Mar 2013)

Setting the map interface language

To set the language, use the following:

nokia.Settings.set("defaultLanguage","de-DE");

For the language, define it in format of ISO3166-1 alpha-2 country code, e.g. en-US, de-DE and so on.

Getting more language information

When you want to display more information, use the class nokia.maps.language.Info.

It has a method called getDefinition (code, [definitions]) : Object.

This will retrieve the language meta data for a given LCID. The look up will be done in two steps: First the full LCID (ISO-639-1 AND ISO-3166-1 alpha-2) will be matched. If the full LCID cannot be found the more general form (ISO-639-1 only) will be matched.

An example of using the getDefinition() method:

     mylanguage = nokia.maps.language.Info;

Would return:

Object { definitions={...}, translations={...}, more...}

then...

   mylanguage.getDefinition("de-DE");

would return e.g:

Object { key="de", iso639_1="de", more...}

Summary

Please check out the chapter http://developer.here.net/docs/maps_js/topics/language-support.html for more information on languages.

327 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved