Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Commit

Permalink
#875 Telegram group links were localized.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemGoryunov committed Aug 3, 2018
1 parent 411554e commit 8b773e9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Trust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@
A2B7ECAE2039001300828E7D /* ExportPrivateKeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2B7ECAD2039001300828E7D /* ExportPrivateKeyViewController.swift */; };
A2E43B4E20802879001FAD3D /* UINavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E43B4D20802879001FAD3D /* UINavigationController.swift */; };
A2E895D020953404003D5303 /* QRGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E895CF20953404003D5303 /* QRGenerator.swift */; };
ACE3F4EC211485F8003CB0A0 /* NSLocale.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */; };
BB03A86D20416AF600649DA0 /* BalanceStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB03A86C20416AF600649DA0 /* BalanceStatus.swift */; };
BB03A8712042B01300649DA0 /* BalanceStatusTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB03A8702042B01300649DA0 /* BalanceStatusTests.swift */; };
BB1CC266203BA4440042E56C /* SendMaxAmountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1CC265203BA4440042E56C /* SendMaxAmountTest.swift */; };
Expand Down Expand Up @@ -941,6 +942,7 @@
A2E895CF20953404003D5303 /* QRGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRGenerator.swift; sourceTree = "<group>"; };
A3B747245A27436E621E7E41 /* Pods-TrustUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TrustUITests/Pods-TrustUITests.release.xcconfig"; sourceTree = "<group>"; };
A48A17FC2CC895AF2BB871D0 /* Pods_TrustTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TrustTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLocale.swift; sourceTree = "<group>"; };
B13A87D3BA5167741E5D0801 /* Pods-Trust.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Trust.release.xcconfig"; path = "Pods/Target Support Files/Pods-Trust/Pods-Trust.release.xcconfig"; sourceTree = "<group>"; };
BB03A86C20416AF600649DA0 /* BalanceStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceStatus.swift; sourceTree = "<group>"; };
BB03A8702042B01300649DA0 /* BalanceStatusTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceStatusTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1573,6 +1575,7 @@
77B64100209668FF00BEF3EB /* EtherNumberFormatter+Trust.swift */,
296FC5A520C2773B00B923EF /* UIScrollView.swift */,
771DC9D420F36555003E2CE2 /* UIBarButtonItem.swift */,
ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -3017,6 +3020,7 @@
297800521F71FDCF003185C1 /* FormAppearance.swift in Sources */,
77B3BF3C201908ED00EEC15A /* ConfirmCoordinator.swift in Sources */,
7704837020FFD2F700837735 /* TransactionsViewController.swift in Sources */,
ACE3F4EC211485F8003CB0A0 /* NSLocale.swift in Sources */,
2928500E2096A69E00EC5AFB /* AboutViewModel.swift in Sources */,
298542F91FBE9A0100CB5081 /* CryptoAddressValidator.swift in Sources */,
7778713C2086AD9900CF7303 /* BigInt.swift in Sources */,
Expand Down
12 changes: 12 additions & 0 deletions Trust/Extensions/NSLocale.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright DApps Platform Inc. All rights reserved.

import Foundation
import UIKit

extension NSLocale {
static var preferredLanguageCode: String? {
let langageRegion = NSLocale.preferredLanguages.first ?? ""
let languageComponents = NSLocale.components(fromLocaleIdentifier: langageRegion)
return languageComponents[NSLocale.Key.languageCode.rawValue]
}
}
4 changes: 3 additions & 1 deletion Trust/Settings/Types/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public struct Constants {
// social
public static let website = "https://trustwalletapp.com"
public static let twitterUsername = "trustwalletapp"
public static let telegramUsername = "trustwallet"
public static let defaultTelegramUsername = "trustwallet"
public static let facebookUsername = "trustwalletapp"

public static var localizedTelegramUsernames = ["ru": "trustwallet_ru", "vi": "trustwallet_vn", "es": "trustwallet_es", "zh": "trustwallet_cn", "ja": "trustwallet_jp", "de": "trustwallet_de", "fr": "trustwallet_fr"]

// support
public static let supportEmail = "[email protected]"
public static let donationAddress = "0x9f8284ce2cf0c8ce10685f537b1fff418104a317"
Expand Down
8 changes: 6 additions & 2 deletions Trust/Settings/Types/ServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ enum URLServiceProvider {
case .twitter:
return URL(string: "twitter://user?screen_name=\(Constants.twitterUsername)")!
case .telegram:
return URL(string: "tg://resolve?domain=\(Constants.telegramUsername)")
let languageCode = NSLocale.preferredLanguageCode ?? ""
let telegramUsername = Constants.localizedTelegramUsernames[languageCode] ?? Constants.defaultTelegramUsername
return URL(string: "tg://resolve?domain=\(telegramUsername)")
case .facebook:
return URL(string: "fb://profile?id=\(Constants.facebookUsername)")
case .discord: return nil
Expand All @@ -58,7 +60,9 @@ enum URLServiceProvider {
case .twitter:
return "https://twitter.com/\(Constants.twitterUsername)"
case .telegram:
return "https://telegram.me/\(Constants.telegramUsername)"
let languageCode = NSLocale.preferredLanguageCode ?? ""
let telegramUsername = Constants.localizedTelegramUsernames[languageCode] ?? Constants.defaultTelegramUsername
return "https://telegram.me/\(telegramUsername)"
case .facebook:
return "https://www.facebook.com/\(Constants.facebookUsername)"
case .discord:
Expand Down

0 comments on commit 8b773e9

Please sign in to comment.