fga-gpp-mds/2017.1-OndeE-UnB

View on GitHub
darcyWeb/app/assets/javascripts/map/routes/translations.js

Summary

Maintainability
A
25 mins
Test Coverage
const routesTranslations = {

  // Routes for to walk mode
  "You have arrived at your destination.": "Você chegou ao seu destino.",
  "Your destination is on the left.": "Seu destino está à esquerda.",
  "Your destination is on the right.": "Seu destino está à direita.",
  "Your destination is on the north.": "Seu destino está ao norte.",
  "Your destination is on the south.": "Seu destino está ao sul.",

  "Walk southeast.": "Ande em direção sudeste.",
  "Walk northeast.": "Ande em direção nordeste.",
  "Walk northwest.": "Ande em direção noroeste.",
  "Walk southwest.": "Ande em direção sudoeste.",
  "Walk east.": "Ande para o leste.",
  "Walk west.": "Ande para o oeste.",
  "Walk south.": "Ande para o sul.",
  "Walk north.": "Ande para o norte.",

  "Continue.": "Continue.",
  "Turn left.": "Vire à esquerda.",
  "Turn right.": "Vire à direita.",
  "Turn north.": "Vire para o norte.",
  "Turn south.": "Vire para o sul.",

  "Bear right.": "Fique à direita.",
  "Bear left.": "Fique à esquerda.",
  "Bear north.": "Fique ao norte.",
  "Bear south.": "Fique ao sul.",

  "Continue on the walkway.": "Continue na calçada.",
  "Turn right onto the walkway.": "Vire à direita na calçada.",
  "Turn left onto the walkway.": "Vire à esquerda na calçada.",
  "Walk east on the walkway.": "Ande para o leste na calçada.",
  "Walk south on the walkway.": "Ande para o sul na calçada.",
  "Walk west on the walkway.": "Ande para o oeste na calçada.",
  "Walk north on the walkway.": "Ande para o norte na calçada.",
  "Walk northeast on the walkway.": "Ande para o nordeste na calçada.",
  "Walk northwest on the walkway.": "Ande para o noroeste na calçada.",
  "Walk southeast on the walkway.": "Ande para o sudeste na calçada.",
  "Walk southwest on the walkway.": "Ande para o sudoeste na calçada.",

  "Bear left onto the walkway.": "Fique à esquerda na calçada.",
  "Bear right onto the walkway.": "Fique à direita na calçada.",
  "Bear north onto the walkway.": "Fique ao norte na calçada.",
  "Bear south onto the walkway.": "Fique ao sul na calçada.",

  "Enter the roundabout and take the 1st exit.": "Entre na rotatória e pegue a 1ª saída.",
  "Enter the roundabout and take the 2nd exit.": "Entre na rotatória e pegue a 2ª saída.",
  "Enter the roundabout and take the 3rd exit.": "Entre na rotatória e pegue a 3ª saída.",
  "Enter the roundabout and take the 4rd exit.": "Entre na rotatória e pegue a 4ª saída.",
  "Exit the roundabout.": "Saia da rotatória.",

  "Make a left U-turn.": "Faça uma curva para a esquerda.",
  "Make a right U-turn.": "Faça uma curva para a direita.",
  "Make a left U-turn onto the walkway.": "Faça uma curva para a esquerda na calçada.",
  "Make a right U-turn onto the walkway.": "Faça uma curva para a direita na calçada.",

  "Turn sharp right onto the walkway.": "Vire a curva à direita na calçada.",
  "Turn sharp left onto the walkway.": "Vire a curva à esquerda na calçada.",
  "Turn sharp right.": "Vire a curva à direita.",
  "Turn sharp left.": "Vire a curva à esquerda.",

  // Routes for by car mode
  "Drive east.": "Siga em direção leste.",
  "Drive west.": "Siga em direção oeste.",
  "Drive right.": "Siga à direita.",
  "Drive left.": "Siga à esquerda.",
  "Drive north.": "Siga em direção norte.",
  "Drive south.": "Siga em direção sul.",
  "Drive southeast.": "Siga em direção sudeste.",
  "Drive northeast.": "Siga em direção nordeste.",
  "Drive northwest.": "Siga em direção noroeste.",
  "Drive southwest.": "Siga em direção sudeste.",

  // Routes for by bike mode
  "Bike east.": "Pedale em direção leste.",
  "Bike west.": "Pedale em direção oeste.",
  "Bike right.": "Pedale à direita.",
  "Bike left.": "Pedale à esquerda.",
  "Bike north.": "Pedale em direção norte.",
  "Bike south.": "Pedale em direção sul.",
  "Bike southeast.": "Pedale em direção sudeste.",
  "Bike northeast.": "Pedale em direção nordeste.",
  "Bike northwest.": "Pedale em direção noroeste.",
  "Bike southwest.": "Pedale em direção sudeste.",

  "Turn left onto the cycleway.": "Vire à esquerda na ciclovia.",
  "Turn right onto the cycleway.": "Vire à direita na ciclovia.",
  "Turn north onto the cycleway.": "Vire ao norte na ciclovia.",
  "Turn south onto the cycleway.": "Vire ao sul na ciclovia.",

  "Bear left onto the cycleway.": "Fique à esquerda na ciclovia.",
  "Bear right onto the cycleway.": "Fique à direita na ciclovia.",
  "Bear north onto the cycleway.": "Fique ao norte na ciclovia.",
  "Bear south onto the cycleway.": "Fique ao sul na ciclovia.",

  "Bike east on the cycleway.": "Pedale em direção leste na ciclovia.",
  "Bike west on the cycleway.": "Pedale em direção oeste na ciclovia.",
  "Bike right on the cycleway.": "Pedale à direita na ciclovia.",
  "Bike left on the cycleway.": "Pedale à esquerda na ciclovia.",
  "Bike north on the cycleway.": "Pedale em direção norte na ciclovia.",
  "Bike south on the cycleway.": "Pedale em direção sul na ciclovia.",
  "Bike southeast on the cycleway.": "Pedale em direção sudeste na ciclovia.",
  "Bike northeast on the cycleway.": "Pedale em direção nordeste na ciclovia.",
  "Bike southwest on the cycleway.": "Pedale em direção sudeste na ciclovia.",
  "Bike northwest on the cycleway.": "Pedale em direção noroeste na ciclovia.",

  "Take the ramp on the left.": "Pegue a rampa à esquerda",
  "Take the ramp on the right.": "Pegue a rampa à direita",
  "Turn right to take the ramp.": "Vire a direita para pegar a rampa",
  "Turn left to take the ramp.": "Vire a esquerda para pegar a rampa",

  // Custom Routes
  "Turn right onto": "Vire a direita em",
  "Turn left onto": "Vire a esquerda em",

  "Turn right to stay on": "Vire a direita para ficar em",
  "Turn left to stay on": "Vire a esquerda para ficar em",

  "Make a right U-turn to stay on": "Faça uma curva à direita para ficar em" ,
  "Make a left U-turn to stay on": "Faça uma curva à esquerda para ficar em" ,

  "Bear left onto": "Fique à esquerda em",
  "Bear right onto": "Fique à direita em",

  "Turn sharp right onto": "Vire à direita para",
  "Turn sharp left onto": "Vire à esquerda para",

  "Drive southeast on": "Siga para o sudeste em",
  "Drive northeast on": "Siga para o nordeste em",
  "Drive northwest on ": "Siga para o noroeste em",
  "Drive southwest on": "Siga para o sudoeste em",
  "Drive east on": "Siga para o leste em",
  "Drive south on": "Siga para o sul em",
  "Drive west on": "Siga para o oeste em",
  "Drive north on": "Siga para o norte em",

  "Walk southeast on": "Ande para o sudeste em",
  "Walk northeast on": "Ande para o nordeste em",
  "Walk northwest on ": "Ande para o noroeste em",
  "Walk southwest on": "Ande para o sudoeste em",
  "Walk east on": "Ande para o leste em",
  "Walk south on": "Ande para o sul em",
  "Walk west on": "Ande para o oeste em",
  "Walk north on": "Ande para o norte em",

  "Bike southeast on": "Pedale para o sudeste em",
  "Bike northeast on": "Pedale para o nordeste em",
  "Bike northwest on": "Pedale para o noroeste em",
  "Bike southwest on": "Pedale para o sudoeste em",
  "Bike east on": "Pedale para o leste em",
  "Bike west on": "Pedale para o oeste em",
  "Bike north on": "Pedale para o norte em",
  "Bike south on": "Pedale para o sul em",

  "Exit the roundabout onto": "Saia da rotatória para"
};


function translateRoute(input) {
  var originalInstr = input;

  var translatedInstr = originalInstr;
  for (var englishInstr in routesTranslations) {
      if (routesTranslations.hasOwnProperty(englishInstr)) {
          
          if(originalInstr.indexOf(englishInstr) !== -1) {
            translatedInstr = originalInstr.replace(englishInstr,routesTranslations[englishInstr]);
            break;
          }
      }
  }

  return translatedInstr;
}