VisioWeb 1.9.5

Class

visioweb.NavigationTranslator

VisioWeb's class responsible for translating navigation instructions and handling several languages.
Instantiated by visioweb.Mapviewer#setupNavigationTranslator.

Constructor

new NavigationTranslator()

Since:
  • 1.9.3 instantiated by visioweb.Mapviewer
See:
Examples
mapviewer.setupNavigationTranslator(vgPlaces);
var languageString = 'en'; // 'fr'
mapviewer.navigationTranslator.translateInstructions(routeResultData.navigation, languageString);
vgPlaces must have the form

{
    placeID001: {
        name: 'shop #001',
        description: 'the first shop'
    },
    placeID002: {
        name: 'shop #002',
        description: 'the second shop'
    },
    ...
}

Methods summary


Name Description
addOrUpdateLanguage adds a new language to the translator or updates an existing one
getLanguage returns a JSON string with the targeted localization. can be used as a template for adding a new language using getLanguage('default')
getLanguageCodes returns an array of supported language codes
translateInstructions translates all the instructions in pNavigation.instructions, augmenting each instruction with .brief, .detailed, .duration, .durationInSeconds
updateDurationForLanguage updates the localized string for a given duration in a given language
updateKeywordForLanguage updates the localized string for a given keyword in a given language
updateManeuverForLanguage updates the localized string for a given maneuver in a given language
updateNextManeuverForLanguage updates the localized string for a given next maneuver (maneuver following another) in a given language

Methods detail

addOrUpdateLanguage(pLanguageCode, pJSONString) → {boolean}

adds a new language to the translator or updates an existing one
Parameters:
Name Type Description
pLanguageCode string short string describing how you will refer to it later. Default language codes are 'en' and 'fr'.
pJSONString string JSON string describing an object of the form: { maneuvers: {...}, // map of strings providing the localization for all maneuvers nextManeuvers: {...}, // map of strings providing the localization for all maneuvers keywords: {...}, // map of strings providing the localization for all keywords durations: {...} // map of strings providing the localization for all durations }
See:
Returns:
Type
boolean

getLanguage(pLanguageCode) → {string|false}

returns a JSON string with the targeted localization. can be used as a template for adding a new language using getLanguage('default')
Parameters:
Name Type Description
pLanguageCode string the targeted language code
Returns:
Type
string | false

getLanguageCodes() → {Array.<string>}

returns an array of supported language codes
Returns:
Type
Array.<string>

translateInstructions(pNavigation, pLanguageStringopt)

translates all the instructions in pNavigation.instructions, augmenting each instruction with .brief, .detailed, .duration, .durationInSeconds
Parameters:
Name Type Attributes Default Description
pNavigation Array object describing the navigation and containing the array of instructions
pLanguageString string <optional>
'en' language string like 'en' or 'fr', must be in cLanguageMap, defaults to 'en' if not found.
Since:
  • 1.7.17 updated signature with mergeFloorChangeInstructions

updateDurationForLanguage(pDuration, pLanguageCode, pDurationString) → {boolean}

updates the localized string for a given duration in a given language
Parameters:
Name Type Description
pDuration string string describing the duration type
pLanguageCode string short string describing the targeted language
pDurationString string new localized string for duration
Returns:
Type
boolean

updateKeywordForLanguage(pKeyword, pLanguageCode, pKeywordString) → {boolean}

updates the localized string for a given keyword in a given language
Parameters:
Name Type Description
pKeyword string string describing the keyword type
pLanguageCode string short string describing the targeted language
pKeywordString string new localized string for keyword
Returns:
Type
boolean

updateManeuverForLanguage(pManeuver, pLanguageCode, pManeuverString) → {boolean}

updates the localized string for a given maneuver in a given language
Parameters:
Name Type Description
pManeuver string string describing the maneuver type
pLanguageCode string short string describing the targeted language
pManeuverString string new localized string for maneuver
Returns:
Type
boolean

updateNextManeuverForLanguage(pManeuver, pLanguageCode, pManeuverString) → {boolean}

updates the localized string for a given next maneuver (maneuver following another) in a given language
Parameters:
Name Type Description
pManeuver string string describing the maneuver type
pLanguageCode string short string describing the targeted language
pManeuverString string new localized string for next maneuver
Returns:
Type
boolean