smartling_rails 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +95 -2
- data/lib/smartling_rails/config.rb +3 -3
- data/lib/smartling_rails/smartling_processor.rb +1 -1
- data/lib/smartling_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 717f0ee405949bddbb8480a1f11e4635ea9016f1
|
4
|
+
data.tar.gz: 26880aa15a108be5ff5e8b1566381dbe3dec347b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce9a145ad5362b3ac8044f14c4dc1997da09f173245b8efb6775f7470598cdae750e42c5955b8ee460cf0b85a12ae7cc9766de51f6fe15a9f67c062dac9fef1
|
7
|
+
data.tar.gz: 5e36c29103304b94e5406cd47b4bc73b5bed4fff61386e86582618bd1975a8998f5cb2df1abac3e32685b4fd2e2931a1cffc165655cf6330b181072aa711ddd9
|
data/README.md
CHANGED
@@ -1,2 +1,95 @@
|
|
1
|
-
#
|
2
|
-
Gem
|
1
|
+
# Welcome to Smartling Rails
|
2
|
+
SmartlingRails is a gem making localization with the [smartling](www.smartling.com) localization service easier in a ruby on rails environment. The Gem simplifies the uploading, status checking, and retrieval of information from smartling into a rails app that uses I18N localization.
|
3
|
+
|
4
|
+
Communication with smartling is done via their APIs and leverages the [smartling gem](https://rubygems.org/gems/smartling).
|
5
|
+
|
6
|
+
## overview
|
7
|
+
The uploading of [rials I18N](http://guides.rubyonrails.org/i18n.html) files to smartling, monitoring their translation status, and pulling them all back down into your `config/localization` folder is a very manual process.
|
8
|
+
|
9
|
+
We wanted to create a way to simplify the process of localization within our project workflow and automate as much of the process as possible.
|
10
|
+
|
11
|
+
This gem is a core part of that automation because it understands how to safely send I18N files to smarling and safely retrieve their translated counterparts back.
|
12
|
+
|
13
|
+
Translating files with smartling is now as easy a little configuration and two commands.
|
14
|
+
|
15
|
+
|
16
|
+
## usage
|
17
|
+
|
18
|
+
```
|
19
|
+
$> gem install smartling_rails
|
20
|
+
$> irb
|
21
|
+
-> require 'smartling_rails'
|
22
|
+
-> sr = SmartlingRails.processor
|
23
|
+
|
24
|
+
-> sr.get_file_statuses
|
25
|
+
Checking status for ["French fr-FR", "German de-DE", "Dutch nl-NL"]
|
26
|
+
fr-FR completed: false (158 / 161)
|
27
|
+
de-DE completed: true (161 / 161)
|
28
|
+
nl-NL completed: true (161 / 161)
|
29
|
+
|
30
|
+
-> sr.put_files
|
31
|
+
Uploading the english file to smartling to process:
|
32
|
+
uploading config/locales/en-us.yml to /files/[PROJECT_NAME]-[GIT_BRANCH_NAME]-en-us-.yml
|
33
|
+
|
34
|
+
-> sr.get_files
|
35
|
+
Checking status for ["French fr-FR", "German de-DE", "Dutch nl-NL"]
|
36
|
+
|
37
|
+
Downloading fr-FR:
|
38
|
+
file loaded...
|
39
|
+
Fixing Issues:
|
40
|
+
fixing tabs from 4 spaces to 2 space
|
41
|
+
removing space after branch root : \n to :\n
|
42
|
+
remove "---" from first line
|
43
|
+
yes, replaced dashes
|
44
|
+
converting smartling locale code to CB locale code
|
45
|
+
|
46
|
+
Downloading de-DE:
|
47
|
+
file loaded...
|
48
|
+
Fixing Issues:
|
49
|
+
fixing tabs from 4 spaces to 2 space
|
50
|
+
removing space after branch root : \n to :\n
|
51
|
+
remove "---" from first line
|
52
|
+
yes, replaced dashes
|
53
|
+
converting smartling locale code to CB locale code
|
54
|
+
|
55
|
+
Downloading nl-NL:
|
56
|
+
file loaded...
|
57
|
+
Fixing Issues:
|
58
|
+
fixing tabs from 4 spaces to 2 space
|
59
|
+
removing space after branch root : \n to :\n
|
60
|
+
remove "---" from first line
|
61
|
+
yes, replaced dashes
|
62
|
+
converting smartling locale code to CB locale code
|
63
|
+
|
64
|
+
```
|
65
|
+
|
66
|
+
## structure
|
67
|
+
The smartling_rails gem consists of 3 components
|
68
|
+
|
69
|
+
**the Config class**
|
70
|
+
The config class loads and provides access for the configuration of the gem and how it interacts with your local application as well as the smartling APIs:
|
71
|
+
- **api_key** the api key for your smarling account
|
72
|
+
- **project_id** the smartling project id
|
73
|
+
- **locales** the hash of locales you support (locally and/or on smarlting)
|
74
|
+
|
75
|
+
**the SmartlingProcessor class**
|
76
|
+
The smartling processor class is responsible for defining the commands of the gem. The ability to upload, download, and get status for the translations is done in this class.
|
77
|
+
|
78
|
+
**the SmartlingFile class**
|
79
|
+
The smartling file class is responsible for the processing of the smartling YAML response to correct a handful of YAML problems that occur when using Smartling's YAML service. These include, removal of '---' from the file's first line, converting 4 spaces per tab to 2 spaces, removing misc spaces after nodes, converting smartling codes to local codes (if needed).
|
80
|
+
|
81
|
+
|
82
|
+
## configuration
|
83
|
+
The configuration of how smartling_rails processes information to/from your application and smarting is done in the following ways:
|
84
|
+
|
85
|
+
Local `.env` file
|
86
|
+
>SMARTLING_API_KEY=[your_smartling_api_key]
|
87
|
+
|
88
|
+
>SMARTLING_PROJECT_ID=[your_project_id]
|
89
|
+
|
90
|
+
ENV (pending)
|
91
|
+
Yaml (pending)
|
92
|
+
|
93
|
+
## dependencies
|
94
|
+
smartling_rails is dependant on the [smartling gem](https://rubygems.org/gems/smartling) version 0.5.1 or higher.
|
95
|
+
|
@@ -21,10 +21,10 @@ module SmartlingRails
|
|
21
21
|
File.open(".env", "rb") do |f|
|
22
22
|
f.each_line do |line|
|
23
23
|
key_val = line.split("=")
|
24
|
-
@api_key = key_val[1].
|
25
|
-
@project_id = key_val[1].
|
24
|
+
@api_key = key_val[1].strip if key_val[0] == 'SMARTLING_API_KEY'
|
25
|
+
@project_id = key_val[1].strip if key_val[0] == 'SMARTLING_PROJECT_ID'
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end unless !File.exist?('.env')
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|