Skip to content

Commit

Permalink
localize, hanlde points
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby Sudekum committed Apr 18, 2017
1 parent c201373 commit 98d53dc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions MapboxNavigation/RouteMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class RouteMapViewController: UIViewController, PulleyPrimaryContentControllerDe
var shieldImageDownloadToken: SDWebImageDownloadToken?
var arrowCurrentStep: RouteStep?

let streetsLanguages = ["zh", "ru", "fr", "es", "en"]

var simulatesLocationUpdates: Bool {
guard let parent = parent as? NavigationViewController else { return false }
return parent.simulatesLocationUpdates
Expand Down Expand Up @@ -286,11 +288,11 @@ extension RouteMapViewController: NavigationMapViewDelegate {
if let userPuck = mapView.view(for: userLocation) {

let lineLayers = style.layers.flatMap {
$0 as? MGLLineStyleLayer
$0 as? MGLVectorStyleLayer
}

let layerIdentifiers = lineLayers.filter {
streetsSourceIdentifiers.contains($0.sourceIdentifier ?? "") && $0.sourceLayerIdentifier == "road"
streetsSourceIdentifiers.contains($0.sourceIdentifier ?? "") && $0.sourceLayerIdentifier == "road_label"
}.map {
$0.identifier
}
Expand All @@ -299,7 +301,18 @@ extension RouteMapViewController: NavigationMapViewDelegate {

for feature in features {
// TODO: Localize
if let name = feature.attribute(forKey: "name") as? String {

for attribute in feature.attributes {
print(attribute)
}

var key = "name"
if let language = Locale.preferredLanguages.first!.components(separatedBy: "-").first,
streetsLanguages.contains(language) {
key += "_\(language)"
}

if let name = feature.attribute(forKey: key) as? String {
wayNameLabel.text = name
wayNameLabel.sizeToFit()
wayNameLabel.isHidden = false
Expand Down

0 comments on commit 98d53dc

Please sign in to comment.