applyrics 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c9c5d1a8b7ca2ceeb42846d525159c6b3f5e6b9
4
+ data.tar.gz: 8073a60f281b76a59d135f005ad276316fd55c85
5
+ SHA512:
6
+ metadata.gz: 3424593e1a0309458242b5b14d0527a188f9045389911e3fa36f0428b89d941143ef14ebb659b49d7ccdf64ba36487111a22dc31ba5ed7888104348c9c21b3ce
7
+ data.tar.gz: 882a30f205e864f941ac9fb05224a348cdd3a36d90033863f1c4bf489b7b19af7ace3a7fc40dc6dcf2843269d57f38496177ebf83a541038d1da04fa6782d874
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Frederik Wallner
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.
@@ -0,0 +1,58 @@
1
+ # Applyrics
2
+ [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/applyrics/applyrics-gem/blob/master/LICENSE)
3
+ [![Build Status](https://img.shields.io/travis/applyrics/applyrics-gem.svg)](https://travis-ci.org/applyrics/applyrics-gem)
4
+ [![Coveralls](https://img.shields.io/coveralls/applyrics/applyrics-gem.svg)](https://coveralls.io/github/applyrics/applyrics-gem)
5
+ [![Gem](https://img.shields.io/gem/v/applyrics.svg)](http://rubygems.org/gems/applyrics)
6
+
7
+ Manage your localization with confidence.
8
+
9
+ ## Disclaimer
10
+
11
+ ---
12
+ This software should be considered ***pre-alpha*** and may thus be incomplete and contain bugs.
13
+ ---
14
+
15
+ ## Status
16
+
17
+ | Feature | iOS | Android |
18
+ | --------- | --- | --------|
19
+ | init | :x: | :x: |
20
+ | rebuild | :x: | :x: |
21
+ | apply | :x: | :x: |
22
+ | sync | :x: | :x: |
23
+
24
+ ## Installation
25
+
26
+ Install using ruby gems:
27
+
28
+ sudo gem install applyrics --verbose
29
+
30
+
31
+ ## Usage
32
+
33
+ Initialize
34
+ (iOS: :x: Android: :x:)
35
+
36
+ applyrics init
37
+
38
+
39
+ Rebuild language files
40
+ (iOS: :x: Android: :x:)
41
+
42
+ applyrics rebuild
43
+
44
+
45
+ Apply a json language file
46
+ (iOS: :x: Android: :x:)
47
+
48
+ applyrics apply
49
+
50
+ Sync languages
51
+ (iOS: :x: Android: :x:)
52
+
53
+ applyrics sync
54
+
55
+
56
+ ## License
57
+
58
+ [MIT](./LICENSE).
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
3
+
4
+ require 'applyrics'
5
+ require 'applyrics/cli'
6
+
7
+ Applyrics::CLI.start
@@ -0,0 +1,8 @@
1
+ require 'applyrics/info'
2
+ require 'applyrics/tools/genstrings'
3
+ require 'applyrics/setup'
4
+ require 'applyrics/lyricsfile'
5
+ module Applyrics
6
+ class << self
7
+ end
8
+ end
@@ -0,0 +1,78 @@
1
+ require 'commander'
2
+ require 'applyrics/setup'
3
+
4
+ module Applyrics
5
+ class CLI
6
+ include Commander::Methods
7
+
8
+ def self.start
9
+ new.run
10
+ end
11
+
12
+ def run
13
+ program :name, 'applyrics'
14
+ program :version, Applyrics::VERSION
15
+ program :description, Applyrics::DESCRIPTION
16
+ program :help_formatter, :compact
17
+
18
+ command :init do |c|
19
+ c.syntax = "applyrics init"
20
+ c.description = "Sets up the project"
21
+ c.action do |args, options|
22
+
23
+ config = {}
24
+ if agree("Connect to Applyrics.io?")
25
+ ask("Username:")
26
+ ask("Password: ") { |q| q.echo = "*" }
27
+ choice = choose("Project?", :first, :second, :third)
28
+ config[:account_id] = "awesome-account"
29
+ config[:project_key] = choice.to_s
30
+ elsif agree("Use local files?")
31
+ config[:filename] = "lyrics.json"
32
+ end
33
+
34
+ project = Applyrics::Setup.new.run(config)
35
+
36
+ if agree("Rebuild language files?")
37
+ puts "will rebuild..."
38
+ project.rebuild_files()
39
+ end
40
+ end
41
+ end
42
+
43
+ command :rebuild do |c|
44
+ c.syntax = "applyrics rebuild"
45
+ c.description = "Rebuilds language files for your project"
46
+ c.option '--project STRING', String, 'Path to iOS or Android project'
47
+ c.action do |args, options|
48
+ options.default :project => './'
49
+ puts "rebuilding..."
50
+ Applyrics::GenStrings.run("#{options.project}", "#{options.project}")
51
+ end
52
+ end
53
+
54
+ command :apply do |c|
55
+ c.syntax = "applyrics apply"
56
+ c.description = "Applies language from a .json file"
57
+ c.option '--project STRING', String, 'Path to iOS or Android project'
58
+ c.option '--data STRING', String, 'Path to .json file (Default: lyrics.json)'
59
+ c.action do |args, options|
60
+ options.default :project => './', :data => './lyrics.json'
61
+ puts "Not implemented yet... Sorry!"
62
+ end
63
+ end
64
+
65
+ command :sync do |c|
66
+ c.syntax = "applyrics sync"
67
+ c.description = "Syncs language from applyrics.io"
68
+ c.option '--project STRING', String, 'Path to iOS or Android project'
69
+ c.action do |args, options|
70
+ options.default :project => './'
71
+ puts "Not implemented yet... Sorry!"
72
+ end
73
+ end
74
+
75
+ run!
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,57 @@
1
+ require 'pty'
2
+ require 'colored'
3
+
4
+ module Applyrics
5
+ class Command
6
+ class << self
7
+ def which(command)
8
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
9
+
10
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
11
+ exts.each do |ext|
12
+ cmd_path = File.join(path, "#{command}#{ext}")
13
+ return cmd_path if File.executable?(cmd_path) && !File.directory?(cmd_path)
14
+ end
15
+ end
16
+
17
+ return nil
18
+ end
19
+
20
+ def execute(command, show_output=true)
21
+ output = []
22
+ command = command.join(" ") if command.kind_of?(Array)
23
+
24
+ begin
25
+ PTY.spawn(command) do |stdin, stdout, pid|
26
+ stdin.each do |l|
27
+ line = l.strip
28
+ output << line
29
+
30
+ #next unless print_all
31
+
32
+ # Prefix the current line with a string
33
+ #prefix.each do |element|
34
+ # line = element[:prefix] + line if element[:block] && element[:block].call(line)
35
+ #end
36
+ puts line unless !show_output
37
+ end
38
+ Process.wait(pid)
39
+ end
40
+ rescue Errno::EIO
41
+ rescue => ex
42
+ puts "Error".red
43
+ puts ex
44
+ end
45
+
46
+ # Exit status for build command, should be 0 if build succeeded
47
+ status = $?.exitstatus
48
+ if status != 0
49
+ o = output.join("\n")
50
+ puts o
51
+ end
52
+
53
+ return output.join("\n")
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ module Applyrics
2
+ class Environment
3
+ def is_android?
4
+ return false
5
+ end
6
+ def is_ios?
7
+ return false
8
+ end
9
+ def is_unity?
10
+ return false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ module Applyrics
2
+ VERSION = "0.0.1"
3
+ DESCRIPTION = "Handle localization for all your mobile projects"
4
+ end
@@ -0,0 +1,49 @@
1
+ module Applyrics
2
+ class Lyricsfile
3
+ class << self
4
+ def exist?
5
+ File.exist?("./Lyricsfile")
6
+ end
7
+ def generate(config=nil)
8
+ template = File.read("#{Gem::Specification.find_by_name('applyrics').gem_dir}/lib/assets/LyricsfileTemplate")
9
+
10
+ if config.key?(:account_id)
11
+ template.gsub!('[[ACCOUNT_ID]]', config[:account_id])
12
+ else
13
+ template.gsub!('[[ACCOUNT_ID]]', 'your-account-id')
14
+ template.gsub!('account:', '# account:')
15
+ end
16
+
17
+ if config.key?(:project_key)
18
+ template.gsub!('[[PROJECT_KEY]]', config[:project_key])
19
+ else
20
+ template.gsub!('[[PROJECT_KEY]]', 'your-project-key')
21
+ template.gsub!('project:', '# project:')
22
+ end
23
+
24
+ if config.key?(:filename)
25
+ template.gsub!('[[FILENAME]]', config[:filename])
26
+ else
27
+ template.gsub!('[[FILENAME]]', 'lyrics.json')
28
+ template.gsub!('filename:', '# filename:')
29
+ end
30
+
31
+ File.write("./Lyricsfile", template)
32
+ end
33
+ end
34
+
35
+ def initialize(path=nil)
36
+ @path = File.expand_path(path)
37
+ parse(File.read(@path))
38
+ end
39
+ def parse_binding
40
+ binding
41
+ end
42
+ def parse(data)
43
+ begin
44
+ eval(data, parse_binding)
45
+ rescue SyntaxError => ex
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,32 @@
1
+ require 'i18n_data'
2
+ require 'applyrics/project_ios'
3
+ module Applyrics
4
+ class Project
5
+ def initialize(platform, path="")
6
+ @platform = platform
7
+
8
+ if @platform == :ios
9
+ @project = Applyrics::Project_iOS.new(path)
10
+ end
11
+
12
+ puts path
13
+ @path = path
14
+ end
15
+
16
+ # @return [Array] An array of languages detected in the project.
17
+ def detected_languages
18
+ @project.detected_languages()
19
+ end
20
+
21
+ # @param [String] the name of the setting to read.
22
+ # @return [String, nil] the value of the setting or nil if not found.
23
+ def platform_project_settings(name)
24
+ @project.platform_project_settings(name)
25
+ end
26
+
27
+ # Rebuild the language files.
28
+ def rebuild_files
29
+ @project.rebuild_files()
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ require 'i18n_data'
2
+ require 'applyrics/tools/genstrings'
3
+ module Applyrics
4
+ class Project_iOS
5
+ def initialize(path)
6
+ if path.to_s.length == 0
7
+ path = Dir["./*.xcworkspace"].first
8
+ end
9
+ if path.to_s.length == 0
10
+ path = Dir["./*.xcodeproj"].first
11
+ end
12
+ @path = path
13
+ @platform_settings = nil
14
+ end
15
+
16
+ # Return a list of detected languages in the project
17
+ def detected_languages
18
+ folder = self.platform_project_settings("SOURCE_ROOT")
19
+ base_language = I18nData.language_code(self.platform_project_settings("DEVELOPMENT_LANGUAGE")).downcase
20
+ lang_folders = Dir.glob(File.join(folder, "**", "*.lproj"))
21
+ @langs = {}
22
+ lang_folders.each do |lang_folder|
23
+ lang = /([A-Za-z\-]*?)\.lproj/.match(lang_folder)[1]
24
+ lang = (lang == "Base" ? base_language : lang)
25
+ @langs[lang] = lang_folder
26
+ end
27
+ end
28
+
29
+ def platform_project_settings(name)
30
+ if @platform_settings.nil?
31
+ cmd = ["set -o pipefail && xcrun xcodebuild -showBuildSettings"]
32
+ cmd << "-project '#{@path}'"
33
+ @platform_settings = Command.execute(cmd, false)
34
+ end
35
+
36
+ result = @platform_settings.split("\n").find { |c| c.split(" = ").first.strip == name }
37
+ return result.split(" = ").last
38
+ end
39
+
40
+ def rebuild_files
41
+ folder = self.platform_project_settings("SOURCE_ROOT")
42
+ Applyrics::GenStrings.run("#{folder}", "#{folder}")
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,39 @@
1
+ require 'commander'
2
+ require 'applyrics/project'
3
+ require 'applyrics/lyricsfile'
4
+ module Applyrics
5
+ class Setup
6
+
7
+ def run(config = {})
8
+ platform = nil
9
+ if is_ios?
10
+ puts "Found iOS project..."
11
+ platform = :ios
12
+ elsif is_android?
13
+ puts "Found Android project..."
14
+ platform = :android
15
+ elsif is_unity?
16
+ puts "Found Unity project..."
17
+ platform = :unity
18
+ else
19
+ puts "Didn't find any project!"
20
+ return
21
+ end
22
+
23
+ Applyrics::Lyricsfile.generate(config)
24
+ Applyrics::Project.new(platform)
25
+ end
26
+
27
+ def is_ios?
28
+ (Dir["*.xcodeproj"] + Dir["*.xcworkspace"]).count > 0
29
+ end
30
+
31
+ def is_android?
32
+ Dir["*.gradle"].count > 0
33
+ end
34
+
35
+ def is_unity?
36
+ false
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ require 'applyrics/command'
2
+ module Applyrics
3
+ class GenStrings
4
+ class << self
5
+ def run(folder, output_folder=nil)
6
+
7
+ output_folder = folder if output_folder.nil?
8
+
9
+ folder = File.expand_path(folder)
10
+ output_folder = File.expand_path(output_folder)
11
+
12
+ cmd = ["set -o pipefail &&"]
13
+ cmd << Command.which("genstrings")
14
+ cmd << "-o " + Shellwords.escape("#{output_folder}")
15
+ cmd << Shellwords.join(files(folder))
16
+
17
+ puts Command.execute(cmd)
18
+ end
19
+
20
+ def files(folder)
21
+ return Dir.glob(File.join(folder, "**", "*.{m,swift}"))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require 'applyrics/command'
2
+ module Applyrics
3
+ class IBTool
4
+ class << self
5
+ def run(folder, output_folder=nil)
6
+ output_folder = folder if output_folder.nil?
7
+
8
+ folder = File.expand_path(folder)
9
+ output_folder = File.expand_path(output_folder)
10
+
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ # Applyrics.io
2
+ account:[[ACCOUNT_ID]]
3
+ project:[[PROJECT_KEY]]
4
+
5
+ # Name of local language file
6
+ filename:[[FILENAME]]
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: applyrics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Frederik Wallner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '4.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '4.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colored
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: i18n_data
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Handle localization for all your mobile projects
98
+ email: frederik.wallner@gmail.com
99
+ executables:
100
+ - applyrics
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - lib/applyrics/cli.rb
105
+ - lib/applyrics/command.rb
106
+ - lib/applyrics/environment.rb
107
+ - lib/applyrics/info.rb
108
+ - lib/applyrics/lyricsfile.rb
109
+ - lib/applyrics/project.rb
110
+ - lib/applyrics/project_ios.rb
111
+ - lib/applyrics/setup.rb
112
+ - lib/applyrics/tools/genstrings.rb
113
+ - lib/applyrics/tools/ibtool.rb
114
+ - lib/applyrics.rb
115
+ - lib/assets/LyricsfileTemplate
116
+ - bin/applyrics
117
+ - README.md
118
+ - LICENSE
119
+ homepage: https://github.com/applyrics/applyrics-gem
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.0.14
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Handle localization for all your mobile projects
143
+ test_files: []