translatr_toolkit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.buildkite/gem-build.sh +12 -0
- data/.buildkite/pipeline.yaml +12 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +75 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/translatr_toolkit/version.rb +5 -0
- data/lib/translatr_toolkit.rb +53 -0
- data/translatr_toolkit.gemspec +37 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9bfdcd540d2eae0894fc7cc85518e78f5e95f40327574b71ca67ffefa53ad960
|
4
|
+
data.tar.gz: e6641864b990b700ec492a5838c43a915b91315782bb6bf4b62e1305e4dcfb0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e8aabe0a5e3526c3dd7a06cd1d2effe9365caf2bd69c1f922aaea73d3777fa7a7f6ee1f51d2397eb3c1d3c24112d0022e34e3128d2fa5025f64e055c75a95cb
|
7
|
+
data.tar.gz: 369a169bf33f08e0c5c3c8245cbf96484e825eb18c999141a2bb5152b59ee68ab22f999dc8fd7db78077a5bc2c8761f54112ec7a1fd49aabef15e33496b0e9d9
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash -eu
|
2
|
+
|
3
|
+
echo "--- :hammer: Build Gemspec"
|
4
|
+
gem build translatr_toolkit.gemspec
|
5
|
+
|
6
|
+
echo "--- :sleuth_or_spy: Validate Gem Install"
|
7
|
+
gem install --user-install translatr_toolkit-*.gem
|
8
|
+
|
9
|
+
echo "--- :rubygems: Gem Push"
|
10
|
+
echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >>".gem-credentials"
|
11
|
+
chmod 600 ".gem-credentials"
|
12
|
+
gem push --config-file ".gem-credentials" translatr_toolkit-*.gem
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#################
|
2
|
+
# Push to RubyGems
|
3
|
+
#################
|
4
|
+
- label: ":rubygems: Publish to RubyGems"
|
5
|
+
key: "gem-push"
|
6
|
+
if: build.tag != null
|
7
|
+
# Note: We intentionally call a separate `.sh` script here (as opposed to having all the
|
8
|
+
# commands written inline) to avoid leaking a key used in the process in clear in the
|
9
|
+
# BUILDKITE_COMMAND environment variable.
|
10
|
+
command: .buildkite/gem-push.sh
|
11
|
+
agents:
|
12
|
+
queue: "default"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.0
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.3
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
translatr_toolkit (0.1.0)
|
5
|
+
onesky-ruby (~> 1.3)
|
6
|
+
rake (~> 13.0)
|
7
|
+
rspec (~> 3.0)
|
8
|
+
rubocop (~> 0.80)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ast (2.4.2)
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
domain_name (0.5.20190701)
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
17
|
+
http-accept (1.7.0)
|
18
|
+
http-cookie (1.0.4)
|
19
|
+
domain_name (~> 0.5)
|
20
|
+
mime-types (3.4.1)
|
21
|
+
mime-types-data (~> 3.2015)
|
22
|
+
mime-types-data (3.2022.0105)
|
23
|
+
netrc (0.11.0)
|
24
|
+
onesky-ruby (1.3.1)
|
25
|
+
rest-client (~> 2.0)
|
26
|
+
parallel (1.21.0)
|
27
|
+
parser (3.1.0.0)
|
28
|
+
ast (~> 2.4.1)
|
29
|
+
rainbow (3.1.1)
|
30
|
+
rake (13.0.6)
|
31
|
+
regexp_parser (2.2.0)
|
32
|
+
rest-client (2.1.0)
|
33
|
+
http-accept (>= 1.7.0, < 2.0)
|
34
|
+
http-cookie (>= 1.0.2, < 2.0)
|
35
|
+
mime-types (>= 1.16, < 4.0)
|
36
|
+
netrc (~> 0.8)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.2)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.2)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.3)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.3)
|
51
|
+
rubocop (0.93.1)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 2.7.1.5)
|
54
|
+
rainbow (>= 2.2.2, < 4.0)
|
55
|
+
regexp_parser (>= 1.8)
|
56
|
+
rexml
|
57
|
+
rubocop-ast (>= 0.6.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
60
|
+
rubocop-ast (1.15.1)
|
61
|
+
parser (>= 3.0.1.1)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
unf (0.1.4)
|
64
|
+
unf_ext
|
65
|
+
unf_ext (0.0.8)
|
66
|
+
unicode-display_width (1.8.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
x86_64-darwin-21
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
translatr_toolkit!
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
2.2.3
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# TranslatrToolkit
|
2
|
+
|
3
|
+
Welcome to the Translatr Tooklit, a library that interfaces between Translatr and OneSky.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'translatr_toolkit'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install translatr_toolkit
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
TranslationsUtils = TranslatrToolkit::TranslatrToolkit.new \
|
25
|
+
ONESKY_API_KEY, ONESKY_API_SECRET, ONESKY_PROJECT_ID
|
26
|
+
|
27
|
+
TranslationsUtils.upload_template_to_onesky('po/')
|
28
|
+
```
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Tumblr/translatr_toolkit.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "translatr_toolkit"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "translatr_toolkit/version"
|
4
|
+
require "onesky"
|
5
|
+
require "pp"
|
6
|
+
|
7
|
+
module TranslatrToolkit
|
8
|
+
# Utility methods for interfacing between Translatr and OneSky.
|
9
|
+
|
10
|
+
class TranslatrToolkit
|
11
|
+
# Constructor
|
12
|
+
# @param onesky_api_key [String] OneSky API key
|
13
|
+
# @param onesky_api_secret [String] OneSky API secret key
|
14
|
+
# @param onesky_project_id [String] OneSky Project ID
|
15
|
+
def initialize(onesky_api_key, onesky_api_secret, onesky_project_id)
|
16
|
+
client = Onesky::Client.new(onesky_api_key, onesky_api_secret)
|
17
|
+
@project = client.project(onesky_project_id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def upload_template_to_onesky(path_to_source_pot)
|
21
|
+
# Uploads a POT file to OneSky.
|
22
|
+
# @param path_to_source_pot [String] Path to the POT file
|
23
|
+
puts "Uploading #{path_to_source_pot} to OneSky"
|
24
|
+
resp = @project.upload_file(
|
25
|
+
file: path_to_source_pot,
|
26
|
+
file_format: "GNU_POT"
|
27
|
+
)
|
28
|
+
puts "Response code: #{resp.code}"
|
29
|
+
puts "Body: #{resp.body}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_gettext_localizations(lang_code_map, dest_dir)
|
33
|
+
# Downloads PO files for provided languages from OneSky.
|
34
|
+
# @param lang_code_map [Hash] Hash that maps OneSky language codes to another scheme
|
35
|
+
# @param dest_dir [String] Directory to save PO files to
|
36
|
+
lang_code_map.each do |onesky_locale, local_locale|
|
37
|
+
po_file_path = File.join(dest_dir, "#{local_locale || onesky_locale}.po")
|
38
|
+
|
39
|
+
puts "Downloading PO file for '#{onesky_locale}' " + \
|
40
|
+
(local_locale != onesky_locale ? "(Tumblr locale '#{local_locale}') " : "") + \
|
41
|
+
"to #{po_file_path}"
|
42
|
+
|
43
|
+
resp = @project.export_translation(
|
44
|
+
source_file_name: "en.pot",
|
45
|
+
locale: onesky_locale,
|
46
|
+
export_file_name: po_file_path
|
47
|
+
)
|
48
|
+
|
49
|
+
File.open(po_file_path, "w+") { |file| file.write(resp) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/translatr_toolkit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "translatr_toolkit"
|
7
|
+
spec.version = TranslatrToolkit::VERSION
|
8
|
+
spec.authors = ["pleff"]
|
9
|
+
spec.email = ["pearl.leff@tumblr.com"]
|
10
|
+
|
11
|
+
spec.summary = "A library with common function used by Tumblr's Translatr translations pipelines."
|
12
|
+
spec.description = "A library with common OneSky functionality used by Tumblr's Translatr translations pipelines."
|
13
|
+
spec.homepage = "https://github.tumblr.net/Tumblr/translatr_toolkit"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.tumblr.net/Tumblr/translatr_toolkit"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.tumblr.net/Tumblr/translatr_toolkit" # TODO change
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
# Uncomment to register a new dependency of your gem
|
30
|
+
spec.add_dependency "rake", "~> 13.0"
|
31
|
+
spec.add_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_dependency "rubocop", "~> 0.80"
|
33
|
+
spec.add_dependency "onesky-ruby", "~> 1.3"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, checkout our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: translatr_toolkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pleff
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.80'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.80'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: onesky-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
description: A library with common OneSky functionality used by Tumblr's Translatr
|
70
|
+
translations pipelines.
|
71
|
+
email:
|
72
|
+
- pearl.leff@tumblr.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".buildkite/gem-build.sh"
|
78
|
+
- ".buildkite/pipeline.yaml"
|
79
|
+
- ".github/workflows/main.yml"
|
80
|
+
- ".gitignore"
|
81
|
+
- ".rspec"
|
82
|
+
- ".rubocop.yml"
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- lib/translatr_toolkit.rb
|
90
|
+
- lib/translatr_toolkit/version.rb
|
91
|
+
- translatr_toolkit.gemspec
|
92
|
+
homepage: https://github.tumblr.net/Tumblr/translatr_toolkit
|
93
|
+
licenses: []
|
94
|
+
metadata:
|
95
|
+
homepage_uri: https://github.tumblr.net/Tumblr/translatr_toolkit
|
96
|
+
source_code_uri: https://github.tumblr.net/Tumblr/translatr_toolkit
|
97
|
+
changelog_uri: https://github.tumblr.net/Tumblr/translatr_toolkit
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 2.3.0
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.2.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: A library with common function used by Tumblr's Translatr translations pipelines.
|
117
|
+
test_files: []
|