diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1610240
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,19 @@
+language: swift
+osx_image: xcode10
+xcode_project: TranslateBar.xcworkspace
+xcode_scheme: TranslateBar
+podfile: Podfile
+cache:
+- bundler
+- cocoapods
+before_install:
+- bundle install
+- bundle exec pod keys set YandexDictionaryKey $YANDEXAPITRANSLATEKEY TranslateBar
+- bundle exec pod keys set YandexTranslateKey $YANDEXAPIDICTIONARYKEY TranslateBar
+- pod update
+- chmod +x ./install_swiftlint.sh
+install:
+- ./install_swiftlint.sh
+script:
+- swiftlint
+- xcodebuild clean build -workspace TranslateBar.xcworkspace -scheme TranslateBar | xcpretty -c && exit ${PIPESTATUS[0]}
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..88f142f
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+gem 'cocoapods'
+gem 'cocoapods-keys'
\ No newline at end of file
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..e1c3eab
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,22 @@
+
+The MIT License (MIT)
+
+Copyright (c) 2018
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Podfile b/Podfile
index 5f8243d..3e0e844 100644
--- a/Podfile
+++ b/Podfile
@@ -13,7 +13,6 @@ target 'TranslateBar' do
pod 'RxSwift'
pod 'RxCocoa'
- pod 'RxSwiftExt'
pod 'Moya/RxSwift'
pod 'KeyHolder'
pod 'ITSwitch'
diff --git a/Podfile.lock b/Podfile.lock
index 12cd9f0..2b7efa8 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -4,7 +4,7 @@ PODS:
- KeyHolder (3.0.1):
- Magnet (~> 2.3)
- Keys (1.0.1)
- - Magnet (2.3.0)
+ - Magnet (2.3.1)
- Moya/Core (11.0.2):
- Alamofire (~> 4.1)
- Result (~> 3.0)
@@ -12,13 +12,11 @@ PODS:
- Moya/Core
- RxSwift (~> 4.0)
- Result (3.2.4)
- - RxCocoa (4.3.1):
- - RxSwift (~> 4.0)
- - RxSwift (4.3.1)
- - RxSwiftExt (3.3.0):
- - RxSwiftExt/Core (= 3.3.0)
- - RxSwiftExt/Core (3.3.0):
+ - RxAtomic (4.4.0)
+ - RxCocoa (4.4.0):
- RxSwift (~> 4.0)
+ - RxSwift (4.4.0):
+ - RxAtomic (~> 4.4)
DEPENDENCIES:
- ITSwitch
@@ -27,7 +25,6 @@ DEPENDENCIES:
- Moya/RxSwift
- RxCocoa
- RxSwift
- - RxSwiftExt
SPEC REPOS:
https://github.com/cocoapods/specs.git:
@@ -37,9 +34,9 @@ SPEC REPOS:
- Magnet
- Moya
- Result
+ - RxAtomic
- RxCocoa
- RxSwift
- - RxSwiftExt
EXTERNAL SOURCES:
Keys:
@@ -50,13 +47,13 @@ SPEC CHECKSUMS:
ITSwitch: 7ff745d6f2a6910e9194b23e4eab9a843258a478
KeyHolder: 142932db4eac7420b003e2eae94c9a61b8b53cb1
Keys: a576f4c9c1c641ca913a959a9c62ed3f215a8de9
- Magnet: 85344b019d023e26062199aeb5b4ad1f8d41c5df
+ Magnet: f8dac2ffc845ffe68b2dd21c68a801f866f4a098
Moya: a725035953bc1c0eb1be505ab903984501d82440
Result: d2d07204ce72856f1fd9130bbe42c35a7b0fea10
- RxCocoa: 78763c7b07d02455598d9fc3c1ad091a28b73635
- RxSwift: fe0fd770a43acdb7d0a53da411c9b892e69bb6e4
- RxSwiftExt: 81afb48ab0602f503147417baeb3989d64c7687d
+ RxAtomic: eacf60db868c96bfd63320e28619fe29c179656f
+ RxCocoa: df63ebf7b9a70d6b4eeea407ed5dd4efc8979749
+ RxSwift: 5976ecd04fc2fefd648827c23de5e11157faa973
-PODFILE CHECKSUM: 1806b7fe32f97a5c8cb0e2855080d6344ebaf1a1
+PODFILE CHECKSUM: 817654156ded1ef5f7ade7c0dc00ac738eee4a92
COCOAPODS: 1.5.3
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..56e0416
--- /dev/null
+++ b/README.md
@@ -0,0 +1,78 @@
+# Translate Bar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Translate Bar is an macOS app that allows you to translate text directly from your menu bar. Open-source appliction written in Swift using some third party libraries:
+* RxSwift
+* Moya
+* ITSwitch
+* KeyHolder
+
+Translation was implemented via [Yandex Translate API](https://tech.yandex.com/translate/)
+
+## Download
+Download latest version of the application for [macOS](https://github.com/artbobrov/Translate-Bar/releases)
+
+## Building
+Translate Bar uses [CocoaPods](https://github.com/CocoaPods/CocoaPods/) as a dependency manager and [Cocoapods-Keys](https://github.com/orta/cocoapods-keys) to store application keys.
+
+1. Clone project from Github to your local
+```
+git clone https://github.com/artbobrov/Translate-Bar.git
+```
+2. Get your [Yandex Dictionary API key](https://tech.yandex.com/dictionary/) and [Yandex Translate API key](https://tech.yandex.com/translate/)
+3. Install all pods and save Yandex API keys
+Run
+```
+$ pod install
+CocoaPods-Keys has detected a keys mismatch for your setup.
+What is the key for YandexDictionaryKey
+ > YOUR_YANDEX_DICTIONARY_API_KEY
+
+Saved YandexDictionaryKey to Translate Bar.
+What is the key for YandexTranslateKey
+ > YOUR_YANDEX_TRANSLATE_API_KEY
+Saved YandexTranslateKey to Translate Bar.
+Analyzing dependencies
+Fetching podspec for `Keys` from `Pods/CocoaPodsKeys`
+Downloading dependencies
+Installing Alamofire (4.7.3)
+Installing ITSwitch (1.0)
+Installing KeyHolder (3.0.1)
+Using Keys (1.0.1)
+Installing Magnet (2.3.1)
+Installing Moya (11.0.2)
+Installing Result (3.2.4)
+Installing RxAtomic (4.4.0)
+Installing RxCocoa (4.4.0)
+Installing RxSwift (4.4.0)
+Generating Pods project
+Integrating client project
+Sending stats
+Pod installation complete! There are 8 dependencies from the Podfile and 11 total pods installed.
+```
+or later
+```
+pod keys set "YandexDictionaryKey" "YOUR_YANDEX_DICTIONARY_API_KEY"
+pod keys set "YandexTranslateKey" "YOUR_YANDEX_TRANSLATE_API_KEY"
+```
+4. Just run your app in Xcode
+
+## Screenshots
+
+
+
\ No newline at end of file
diff --git a/TranslateBar.xcodeproj/project.pbxproj b/TranslateBar.xcodeproj/project.pbxproj
index f54947d..434dc9c 100644
--- a/TranslateBar.xcodeproj/project.pbxproj
+++ b/TranslateBar.xcodeproj/project.pbxproj
@@ -869,9 +869,9 @@
"${BUILT_PRODUCTS_DIR}/Magnet/Magnet.framework",
"${BUILT_PRODUCTS_DIR}/Moya/Moya.framework",
"${BUILT_PRODUCTS_DIR}/Result/Result.framework",
+ "${BUILT_PRODUCTS_DIR}/RxAtomic/RxAtomic.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
- "${BUILT_PRODUCTS_DIR}/RxSwiftExt/RxSwiftExt.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
@@ -882,9 +882,9 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Magnet.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Moya.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Result.framework",
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxAtomic.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwiftExt.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1091,7 +1091,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -1153,7 +1153,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
@@ -1181,7 +1181,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "TranslateBar/Translate Bar.entitlements";
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = EX9Z9UFRL5;
@@ -1204,10 +1204,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "TranslateBar/Translate Bar.entitlements";
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = EX9Z9UFRL5;
+ GCC_OPTIMIZATION_LEVEL = fast;
INFOPLIST_FILE = TranslateBar/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
diff --git a/TranslateBar.xcodeproj/xcshareddata/xcschemes/TranslateBar.xcscheme b/TranslateBar.xcodeproj/xcshareddata/xcschemes/TranslateBar.xcscheme
new file mode 100644
index 0000000..35dcabc
--- /dev/null
+++ b/TranslateBar.xcodeproj/xcshareddata/xcschemes/TranslateBar.xcscheme
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TranslateBar.xcodeproj/xcuserdata/artembobrov.xcuserdatad/xcschemes/xcschememanagement.plist b/TranslateBar.xcodeproj/xcuserdata/artembobrov.xcuserdatad/xcschemes/xcschememanagement.plist
index 192429e..f308430 100644
--- a/TranslateBar.xcodeproj/xcuserdata/artembobrov.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/TranslateBar.xcodeproj/xcuserdata/artembobrov.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -4,15 +4,20 @@
SchemeUserState
- TranslateBar.xcscheme
+ TranslateBar.xcscheme_^#shared#^_
orderHint
- 13
+ 1
+
+ TranslateBarTests.xcscheme
+
+ orderHint
+ 15
TranslateBar_en.xcscheme_^#shared#^_
orderHint
- 14
+ 0
SuppressBuildableAutocreation
diff --git a/TranslateBar/Controllers/TranslateViewController.swift b/TranslateBar/Controllers/TranslateViewController.swift
index 8f50830..67bc16a 100644
--- a/TranslateBar/Controllers/TranslateViewController.swift
+++ b/TranslateBar/Controllers/TranslateViewController.swift
@@ -81,7 +81,7 @@ class TranslateViewController: NSViewController {
languagePickerSelectedIndex: languagePickerSelectedIndex,
suggenstionLinkClicked: suggenstionLinkClicked.asDriverOnErrorJustComplete(),
translationFromClipboardNeeded: rx.viewWillAppear.asDriver(),
- pinButtonState: appView.bottomBar.pinButton.rx.state.asDriver()
+ pinButtonState: appView.bottomBar.pinButton.rx.state.asDriver()
)
}
diff --git a/TranslateBar/ViewModel/TranslateViewModel.swift b/TranslateBar/ViewModel/TranslateViewModel.swift
index 8fe429a..512c072 100644
--- a/TranslateBar/ViewModel/TranslateViewModel.swift
+++ b/TranslateBar/ViewModel/TranslateViewModel.swift
@@ -102,7 +102,7 @@ extension TranslateViewModel: ViewModelType {
let languagePickerSelectedIndex: Driver
let suggenstionLinkClicked: Driver
let translationFromClipboardNeeded: Driver
- let pinButtonState: Driver
+ let pinButtonState: Driver
}
struct Output {
@@ -187,7 +187,6 @@ extension TranslateViewModel {
let query = String(result.dropLast().joined())
return OnLinkActionQuery(action: action, query: query)
}
-
.drive(onNext: { object in
NotificationCenter.default.post(name: .linkClicked, object: object)
})
@@ -198,12 +197,12 @@ extension TranslateViewModel {
.map { NSPasteboard.clipboard ?? "" }
.drive(inputText)
.disposed(by: disposeBag)
- input.pinButtonState
- .map { $0 == .on ? NSPopover.Behavior.applicationDefined : .transient }
- .drive(onNext: { behavior in
- NSApplication.shared.appDelegate.popover.behavior = behavior
- })
- .disposed(by: disposeBag)
+ input.pinButtonState
+ .map { $0 == .on ? NSPopover.Behavior.applicationDefined : .transient }
+ .drive(onNext: { behavior in
+ NSApplication.shared.appDelegate.popover.behavior = behavior
+ })
+ .disposed(by: disposeBag)
}
private func suggestionsAttributedText(_ value: ([SpellMistake], String)) -> String {
diff --git a/img/icon.png b/img/icon.png
new file mode 100755
index 0000000..28c268b
Binary files /dev/null and b/img/icon.png differ
diff --git a/img/screenshots/language_pick.png b/img/screenshots/language_pick.png
new file mode 100644
index 0000000..58d96e1
Binary files /dev/null and b/img/screenshots/language_pick.png differ
diff --git a/img/screenshots/translate.png b/img/screenshots/translate.png
new file mode 100644
index 0000000..970a03d
Binary files /dev/null and b/img/screenshots/translate.png differ
diff --git a/install_swiftlint.sh b/install_swiftlint.sh
new file mode 100644
index 0000000..62b8c84
--- /dev/null
+++ b/install_swiftlint.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Installs the SwiftLint package.
+# Tries to get the precompiled .pkg file from Github, but if that
+# fails just recompiles from source.
+
+set -e
+
+SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg"
+SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.9.1/SwiftLint.pkg"
+
+wget --output-document=$SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL
+
+if [ -f $SWIFTLINT_PKG_PATH ]; then
+ echo "SwiftLint package exists! Installing it..."
+ sudo installer -pkg $SWIFTLINT_PKG_PATH -target /
+else
+ echo "SwiftLint package doesn't exist. Compiling from source..." &&
+ git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint &&
+ cd /tmp/SwiftLint &&
+ git submodule update --init --recursive &&
+ sudo make install
+fi
+