ios_polyglot_cli 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +129 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +91 -0
  6. data/LICENSE +21 -0
  7. data/README.md +63 -0
  8. data/Rakefile +2 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/exe/polyglot +41 -0
  12. data/ios-polyglot-cli.gemspec +35 -0
  13. data/lib/ios_polyglot_cli/api/base.rb +19 -0
  14. data/lib/ios_polyglot_cli/api/language.rb +20 -0
  15. data/lib/ios_polyglot_cli/api/project.rb +7 -0
  16. data/lib/ios_polyglot_cli/api/session.rb +9 -0
  17. data/lib/ios_polyglot_cli/api/translation.rb +8 -0
  18. data/lib/ios_polyglot_cli/api/translation_key.rb +24 -0
  19. data/lib/ios_polyglot_cli/commands/login.rb +32 -0
  20. data/lib/ios_polyglot_cli/commands/pull.rb +81 -0
  21. data/lib/ios_polyglot_cli/commands/setup.rb +80 -0
  22. data/lib/ios_polyglot_cli/error_handler.rb +28 -0
  23. data/lib/ios_polyglot_cli/helpers/depaginate.rb +18 -0
  24. data/lib/ios_polyglot_cli/helpers/general.rb +79 -0
  25. data/lib/ios_polyglot_cli/helpers/terminal.rb +17 -0
  26. data/lib/ios_polyglot_cli/io/config.rb +20 -0
  27. data/lib/ios_polyglot_cli/io/token.rb +25 -0
  28. data/lib/ios_polyglot_cli/serializers/languages/languages_serializer.rb +27 -0
  29. data/lib/ios_polyglot_cli/serializers/languages/languages_serializer_objc.rb +90 -0
  30. data/lib/ios_polyglot_cli/serializers/languages/languages_serializer_swift.rb +41 -0
  31. data/lib/ios_polyglot_cli/serializers/sources/sources_serializer_swift.rb +63 -0
  32. data/lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_case.rb +23 -0
  33. data/lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_enum.rb +84 -0
  34. data/lib/ios_polyglot_cli/serializers/translations/translations_serializer.rb +33 -0
  35. data/lib/ios_polyglot_cli/version.rb +3 -0
  36. data/lib/ios_polyglot_cli.rb +42 -0
  37. metadata +192 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c70a269cb650575390a356bd3e4868c03cedf3a0f9bb4f6a3742f9d205c25d9a
4
+ data.tar.gz: 9da347e54fbe271f21821718ad21e8a7f7e7dfdefb6aacc9bf74d1b60213c1e8
5
+ SHA512:
6
+ metadata.gz: 657216588118ea21a532ddddcfb1b7e1f39499c5e58e1e94bfb02c49d127ee950533f94011f587b9dfec9d68bd1636e28848ea39b513313727e216e0a556ac97
7
+ data.tar.gz: 0410ba10fab8373e94b3328fdbc4a0125f4e536c2563bdb11455669cd1ba8add6a2b384f2c7cac99faf47907c9cab58a7f5d9d68fcaacc6ea894a1ade83b9be0
data/.gitignore ADDED
@@ -0,0 +1,129 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,xcode,macos,visualstudiocode
3
+ # Edit at https://www.gitignore.io/?templates=ruby,xcode,macos,visualstudiocode
4
+
5
+ ### macOS ###
6
+ # General
7
+ .DS_Store
8
+ .AppleDouble
9
+ .LSOverride
10
+
11
+ # Icon must end with two \r
12
+ Icon
13
+
14
+ # Thumbnails
15
+ ._*
16
+
17
+ # Files that might appear in the root of a volume
18
+ .DocumentRevisions-V100
19
+ .fseventsd
20
+ .Spotlight-V100
21
+ .TemporaryItems
22
+ .Trashes
23
+ .VolumeIcon.icns
24
+ .com.apple.timemachine.donotpresent
25
+
26
+ # Directories potentially created on remote AFP share
27
+ .AppleDB
28
+ .AppleDesktop
29
+ Network Trash Folder
30
+ Temporary Items
31
+ .apdisk
32
+
33
+ ### Ruby ###
34
+ *.gem
35
+ *.rbc
36
+ /.config
37
+ /coverage/
38
+ /InstalledFiles
39
+ /pkg/
40
+ /spec/reports/
41
+ /spec/examples.txt
42
+ /test/tmp/
43
+ /test/version_tmp/
44
+ /tmp/
45
+
46
+ # Used by dotenv library to load environment variables.
47
+ # .env
48
+
49
+ # Ignore Byebug command history file.
50
+ .byebug_history
51
+
52
+ ## Specific to RubyMotion:
53
+ .dat*
54
+ .repl_history
55
+ build/
56
+ *.bridgesupport
57
+ build-iPhoneOS/
58
+ build-iPhoneSimulator/
59
+
60
+ ## Specific to RubyMotion (use of CocoaPods):
61
+ #
62
+ # We recommend against adding the Pods directory to your .gitignore. However
63
+ # you should judge for yourself, the pros and cons are mentioned at:
64
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
65
+ # vendor/Pods/
66
+
67
+ ## Documentation cache and generated files:
68
+ /.yardoc/
69
+ /_yardoc/
70
+ /doc/
71
+ /rdoc/
72
+
73
+ ## Environment normalization:
74
+ /.bundle/
75
+ /vendor/bundle
76
+ /lib/bundler/man/
77
+
78
+ # for a library or gem, you might want to ignore these files since the code is
79
+ # intended to run in multiple environments; otherwise, check them in:
80
+ # Gemfile.lock
81
+ # .ruby-version
82
+ # .ruby-gemset
83
+
84
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
85
+ .rvmrc
86
+
87
+ ### VisualStudioCode ###
88
+ .vscode/*
89
+ !.vscode/settings.json
90
+ !.vscode/tasks.json
91
+ !.vscode/launch.json
92
+ !.vscode/extensions.json
93
+
94
+ ### VisualStudioCode Patch ###
95
+ # Ignore all local history of files
96
+ .history
97
+
98
+ ### Xcode ###
99
+ # Xcode
100
+ # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
101
+
102
+ ## User settings
103
+ xcuserdata/
104
+
105
+ ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
106
+ *.xcscmblueprint
107
+ *.xccheckout
108
+
109
+ ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
110
+ DerivedData/
111
+ *.moved-aside
112
+ *.pbxuser
113
+ !default.pbxuser
114
+ *.mode1v3
115
+ !default.mode1v3
116
+ *.mode2v3
117
+ !default.mode2v3
118
+ *.perspectivev3
119
+ !default.perspectivev3
120
+
121
+ ### Xcode Patch ###
122
+ *.xcodeproj/*
123
+ !*.xcodeproj/project.pbxproj
124
+ !*.xcodeproj/xcshareddata/
125
+ !*.xcworkspace/contents.xcworkspacedata
126
+ /*.gcno
127
+ **/xcshareddata/WorkspaceSettings.xcsettings
128
+
129
+ # End of https://www.gitignore.io/api/ruby,xcode,macos,visualstudiocode
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ios_polyglot_cli (2.0.1)
5
+ activesupport
6
+ commander
7
+ json_api_client
8
+ osx_keychain
9
+ tty-prompt
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ RubyInline (3.12.4)
15
+ ZenTest (~> 4.3)
16
+ ZenTest (4.11.2)
17
+ activemodel (5.2.3)
18
+ activesupport (= 5.2.3)
19
+ activesupport (5.2.3)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (>= 0.7, < 2)
22
+ minitest (~> 5.1)
23
+ tzinfo (~> 1.1)
24
+ addressable (2.6.0)
25
+ public_suffix (>= 2.0.2, < 4.0)
26
+ byebug (11.0.1)
27
+ coderay (1.1.2)
28
+ commander (4.4.7)
29
+ highline (~> 2.0.0)
30
+ concurrent-ruby (1.1.5)
31
+ equatable (0.5.0)
32
+ faraday (0.15.4)
33
+ multipart-post (>= 1.2, < 3)
34
+ faraday_middleware (0.13.1)
35
+ faraday (>= 0.7.4, < 1.0)
36
+ highline (2.0.2)
37
+ i18n (1.6.0)
38
+ concurrent-ruby (~> 1.0)
39
+ json_api_client (1.9.0)
40
+ activemodel (>= 3.2.0)
41
+ activesupport (>= 3.2.0)
42
+ addressable (~> 2.2)
43
+ faraday (~> 0.15, >= 0.15.2)
44
+ faraday_middleware (~> 0.9)
45
+ method_source (0.9.2)
46
+ minitest (5.11.3)
47
+ multipart-post (2.0.0)
48
+ necromancer (0.4.0)
49
+ osx_keychain (1.0.2)
50
+ RubyInline (~> 3)
51
+ pastel (0.7.2)
52
+ equatable (~> 0.5.0)
53
+ tty-color (~> 0.4.0)
54
+ pry (0.12.2)
55
+ coderay (~> 1.1.0)
56
+ method_source (~> 0.9.0)
57
+ pry-byebug (3.7.0)
58
+ byebug (~> 11.0)
59
+ pry (~> 0.10)
60
+ public_suffix (3.0.3)
61
+ rake (10.5.0)
62
+ thread_safe (0.3.6)
63
+ timers (4.3.0)
64
+ tty-color (0.4.3)
65
+ tty-cursor (0.6.1)
66
+ tty-prompt (0.18.1)
67
+ necromancer (~> 0.4.0)
68
+ pastel (~> 0.7.0)
69
+ timers (~> 4.0)
70
+ tty-cursor (~> 0.6.0)
71
+ tty-reader (~> 0.5.0)
72
+ tty-reader (0.5.0)
73
+ tty-cursor (~> 0.6.0)
74
+ tty-screen (~> 0.6.4)
75
+ wisper (~> 2.0.0)
76
+ tty-screen (0.6.5)
77
+ tzinfo (1.2.5)
78
+ thread_safe (~> 0.1)
79
+ wisper (2.0.0)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler (~> 1.16)
86
+ ios_polyglot_cli!
87
+ pry-byebug
88
+ rake (~> 10.0)
89
+
90
+ BUNDLED WITH
91
+ 1.17.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Filip Gulan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+
2
+ # iOS Polyglot CLI
3
+
4
+ Polyglot client for iOS development
5
+
6
+ ## Installation
7
+
8
+ If you use old polyglot-cli or native polyglot please uninstall them first:
9
+
10
+ $ sudo gem uninstall polyglot-cli
11
+ $ brew uninstall --force infinum/formulae/polyglot
12
+
13
+ Then to install polyglot simply run:
14
+
15
+ $ gem install ios_polyglot_cli
16
+
17
+ ## Usage
18
+
19
+ ### Login
20
+
21
+ You will have to login with your Infinum ID if you want to use polyglot:
22
+
23
+ $ polyglot login
24
+
25
+ If your login action is successful, polyglot will ask you to access Keychain. There it will save your access token, so you don’t have to enter your credentials every time when you use `polyglot` command.
26
+
27
+ ### Setup
28
+
29
+ To setup polyglot in your Xcode project use:
30
+
31
+ $ polyglot init
32
+
33
+ It will prompt you with project list to select one you are setting up. You can provide source language (Swift/ObjC), translations path and resources path. It will create `polyglot.yml` file which you can edit later and add additional Polyglot projects.
34
+
35
+ Also, you can pass optional parameter `--query` or `-q`. It will prompt you with a list of all projects that match specified query.
36
+
37
+ ### Legacy projects
38
+
39
+ New style translations will create files names `en_US.strings` for example, and some old projects still use old naming in the style of `en.strings`. To get around this issue, you either need to migrate your project to use the new naming (be mindful of existing app's settings), or add this line under your path value:
40
+
41
+ ```yaml
42
+ useOldNaming: true
43
+ ```
44
+
45
+ ### Pull
46
+
47
+ Finally, to fetch translations use:
48
+
49
+ $ polyglot pull
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+
55
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ios_polyglot_cli.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ios_polyglot_cli'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require 'pry'
11
+ Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/polyglot ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander'
5
+ require 'commander/import'
6
+ require 'ios_polyglot_cli'
7
+
8
+ program :name, 'polyglot'
9
+ program :version, PolyglotIos::VERSION
10
+ program :description, 'An iOS client for managing polyglot\'s translations.'
11
+
12
+ command :login do |c|
13
+ c.syntax = 'polyglot login'
14
+ c.description = 'Fetches and writes your token to the keychain using the email and password you provide.'
15
+ c.action do
16
+ PolyglotIos::ErrorHandler.rescuable do
17
+ PolyglotIos::Command::Login.init
18
+ end
19
+ end
20
+ end
21
+
22
+ command :init do |c|
23
+ c.syntax = 'polyglot init [options]'
24
+ c.description = 'Sets up a polyglot.yml config for selected project.'
25
+ c.option '--query STRING', String, 'Only shows projects that matches string'
26
+ c.action do |_args, options|
27
+ PolyglotIos::ErrorHandler.rescuable do
28
+ PolyglotIos::Command::Setup.init(options)
29
+ end
30
+ end
31
+ end
32
+
33
+ command :pull do |c|
34
+ c.syntax = 'polyglot pull'
35
+ c.description = 'Pulls all translations from Polyglot and generates necessary files'
36
+ c.action do |_args, options|
37
+ PolyglotIos::ErrorHandler.rescuable do
38
+ PolyglotIos::Command::Pull.init
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ios_polyglot_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ios_polyglot_cli'
8
+ spec.version = PolyglotIos::VERSION
9
+ spec.authors = ['Filip Gulan']
10
+ spec.email = ['filip.gulan@infinum.hr']
11
+
12
+ spec.summary = 'A CLI for pulling polyglot translations and generating iOS Source Files'
13
+ spec.homepage = 'https://github.com/infinum/ios-polyglot-cli'
14
+ spec.license = 'MIT'
15
+
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'pry-byebug'
29
+
30
+ spec.add_dependency 'json_api_client'
31
+ spec.add_dependency 'tty-prompt'
32
+ spec.add_dependency 'commander'
33
+ spec.add_dependency 'osx_keychain'
34
+ spec.add_dependency 'activesupport'
35
+ end
@@ -0,0 +1,19 @@
1
+ module PolyglotIos
2
+ module Resource
3
+ class Base < JsonApiClient::Resource
4
+ extend PolyglotIos::Helper::Depaginate
5
+
6
+ self.site = 'https://polyglot.infinum.co/api/v2/'
7
+
8
+ def self.token(token)
9
+ self.connection_options = { headers: { 'X-Auth-Token' => token } }
10
+ self
11
+ end
12
+
13
+ def self.depaginate(opts = {})
14
+ depaginate_query(where(opts))
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,20 @@
1
+ module PolyglotIos
2
+ module Resource
3
+ class Language < Base
4
+
5
+ include Helper::General
6
+
7
+ def code(use_simple_naming = false)
8
+ code = locale.downcase
9
+ return code if !use_simple_naming
10
+ return code.split("_").first
11
+ end
12
+
13
+ def clean_name()
14
+ clean_variable_name(name)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,7 @@
1
+ module PolyglotIos
2
+ module Resource
3
+ class Project < Base
4
+ has_one :default_language, class_name: :language
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module PolyglotIos
2
+ module Resource
3
+
4
+ class Session < Base
5
+ end
6
+
7
+ end
8
+ end
9
+
@@ -0,0 +1,8 @@
1
+ module PolyglotIos
2
+ module Resource
3
+ class Translation < Base
4
+ has_one :translation_key
5
+ has_one :language
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module PolyglotIos
2
+ module Resource
3
+ class TranslationKey < Base
4
+
5
+ def clean_translation(language)
6
+ translation_value = name
7
+ translation = translations.find { |key| key.language.id == language.id }
8
+ if translation && translation.value
9
+ translation_value = translation.value
10
+ end
11
+ escape_translation(translation_value)
12
+ end
13
+
14
+ private
15
+
16
+ def escape_translation(translation)
17
+ translation
18
+ .gsub("\"", "\\\"")
19
+ .gsub("%s", "%@")
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ module PolyglotIos
2
+ module Command
3
+ class Login
4
+ include Helper::Terminal
5
+
6
+ def self.init
7
+ new.call
8
+ end
9
+
10
+ def call
11
+ PolyglotIos::IO::Token.write(token)
12
+ end
13
+
14
+ private
15
+
16
+ def token
17
+ prompt.say('Logging into API...')
18
+ @data = PolyglotIos::Resource::Session.create(email: email, password: password)
19
+ @data.token
20
+ end
21
+
22
+ def email
23
+ prompt.ask('Email:') { |value| value.validate :email }
24
+ end
25
+
26
+ def password
27
+ prompt.mask('Password:')
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,81 @@
1
+ module PolyglotIos
2
+ module Command
3
+ class Pull
4
+ include Helper::Terminal
5
+ include Helper::General
6
+
7
+ def self.init
8
+ new.call
9
+ end
10
+
11
+ def call
12
+ prompt.say("Fetching translations...")
13
+ generate_translations(project_configs, programming_language)
14
+ success("Translations successfully generated!")
15
+ end
16
+
17
+ private
18
+
19
+ def generate_translations(projects, programming_language)
20
+ projects.each do |project|
21
+ project_id = project[:id]
22
+ languages = pull_languages(project_id)
23
+ translation_keys = pull_translation_keys(project_id)
24
+
25
+ write_translations(translation_keys, languages, project[:path], use_old_naming)
26
+ write_languages(languages, project[:sourceFilesPath], programming_language)
27
+ write_translation_sources(translation_keys, project[:sourceFilesPath], programming_language)
28
+ end
29
+ end
30
+
31
+ # Serializing data
32
+
33
+ def write_translations(translation_keys, languages, translations_path, use_old_naming = false)
34
+ return if translations_path.to_s.empty?
35
+ languages.each do |language|
36
+ PolyglotIos::Serializer::Translation
37
+ .write(translation_keys, language, translations_path, use_old_naming)
38
+ end
39
+
40
+ end
41
+
42
+ def write_languages(languages, sources_path, programming_language)
43
+ return if sources_path.to_s.empty?
44
+ case programming_language.downcase
45
+ when "objc"
46
+ serializer = PolyglotIos::Serializer::Language::ObjC
47
+ when "swift"
48
+ serializer = PolyglotIos::Serializer::Language::Swift
49
+ end
50
+ serializer.new(languages).save(sources_path)
51
+ end
52
+
53
+ def write_translation_sources(translation_keys, sources_path, programming_language)
54
+ return if sources_path.to_s.empty?
55
+ case programming_language.downcase
56
+ when "swift"
57
+ serializer = PolyglotIos::Serializer::Source::Swift
58
+ serializer
59
+ .new(translation_keys)
60
+ .save(sources_path)
61
+ end
62
+ end
63
+
64
+ # Pulling data
65
+
66
+ def pull_languages(project_id)
67
+ PolyglotIos::Resource::Language
68
+ .token(token)
69
+ .depaginate(project_id: project_id)
70
+ end
71
+
72
+ def pull_translation_keys(project_id)
73
+ PolyglotIos::Resource::TranslationKey
74
+ .token(token)
75
+ .depaginate(project_id: project_id)
76
+ .sort_by { |key| key.name.downcase }
77
+ end
78
+
79
+ end
80
+ end
81
+ end