wti_gettext_i18n_rails 1.0.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.
- data/MIT-LICENSE +22 -0
- data/README.md +106 -0
- data/bin/wti +5 -0
- data/examples/locale.rb +12 -0
- data/examples/translation.yml +18 -0
- data/generators/webtranslateit/lib/insert_commands.rb +34 -0
- data/generators/webtranslateit/templates/translation.yml +17 -0
- data/generators/webtranslateit/webtranslateit_generator.rb +26 -0
- data/history.md +99 -0
- data/lib/web_translate_it/auto_fetch.rb +22 -0
- data/lib/web_translate_it/command_line.rb +167 -0
- data/lib/web_translate_it/configuration.rb +54 -0
- data/lib/web_translate_it/project.rb +38 -0
- data/lib/web_translate_it/tasks.rb +59 -0
- data/lib/web_translate_it/translation_file.rb +97 -0
- data/lib/web_translate_it/util.rb +35 -0
- data/lib/web_translate_it.rb +20 -0
- data/man/wti.1 +90 -0
- data/man/wti.1.html +157 -0
- data/man/wti.1.ron +81 -0
- data/spec/examples/config/translation.yml +15 -0
- data/spec/examples/en.yml +38 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/web_translate_it/configuration_spec.rb +31 -0
- data/spec/web_translate_it/translation_file_spec.rb +68 -0
- data/spec/web_translate_it/util_spec.rb +10 -0
- data/spec/web_translate_it_spec.rb +27 -0
- data/version.yml +4 -0
- metadata +132 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :trans do
|
4
|
+
desc "Fetch translation files from Web Translate It"
|
5
|
+
task :fetch, :locale do |task, args|
|
6
|
+
welcome_message
|
7
|
+
puts "Fetching file for locale #{args.locale}…"
|
8
|
+
configuration = WebTranslateIt::Configuration.new
|
9
|
+
configuration.files.each do |file|
|
10
|
+
response_code = file.fetch(args.locale)
|
11
|
+
handle_response(file.file_path_for_locale(args.locale), response_code)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :fetch do
|
16
|
+
desc "Fetch all the translation files from Web Translate It"
|
17
|
+
task :all do
|
18
|
+
welcome_message
|
19
|
+
configuration = WebTranslateIt::Configuration.new
|
20
|
+
locales = configuration.target_locales
|
21
|
+
configuration.ignore_locales.each do |ignore|
|
22
|
+
locales.delete(ignore)
|
23
|
+
end
|
24
|
+
puts "Fetching all files for all locales…"
|
25
|
+
locales.each do |locale|
|
26
|
+
configuration.files.each do |file|
|
27
|
+
unless File.exist?(file.file_path_for_directory(locale))
|
28
|
+
Dir.mkdir(file.file_path_for_directory(locale))
|
29
|
+
end
|
30
|
+
response_code = file.fetch(locale)
|
31
|
+
handle_response(file.file_path_for_locale(locale), response_code)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Upload the translation files for a locale to Web Translate It"
|
38
|
+
task :upload, :locale do |task, args|
|
39
|
+
welcome_message
|
40
|
+
puts "Uploading file for locale #{args.locale}…"
|
41
|
+
configuration = WebTranslateIt::Configuration.new
|
42
|
+
configuration.files.each do |file|
|
43
|
+
response_code = file.upload(args.locale)
|
44
|
+
handle_response(file.file_path_for_locale(args.locale), response_code)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def handle_response(file_path, response_code)
|
49
|
+
if response_code < 400
|
50
|
+
puts "#{file_path}: #{response_code}, OK"
|
51
|
+
else
|
52
|
+
puts "#{file_path}: #{response_code}, Problem!"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def welcome_message
|
57
|
+
puts "Web Translate It v#{WebTranslateIt::Util.version}"
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module WebTranslateIt
|
2
|
+
|
3
|
+
# A TranslationFile is the representation of a master language file
|
4
|
+
# on Web Translate It.
|
5
|
+
#
|
6
|
+
# This class allows to manipulate TranslationFiles, more specifically upload and download them.
|
7
|
+
# If you pass a Locale to the master language file you will be able to
|
8
|
+
# manipulate a _target_ language file.
|
9
|
+
class TranslationFile
|
10
|
+
require 'net/https'
|
11
|
+
require 'net/http/post/multipart'
|
12
|
+
require 'time'
|
13
|
+
require 'fileutils'
|
14
|
+
|
15
|
+
attr_accessor :id, :file_path, :api_key
|
16
|
+
|
17
|
+
def initialize(id, file_path, api_key)
|
18
|
+
self.id = id
|
19
|
+
self.file_path = file_path
|
20
|
+
self.api_key = api_key
|
21
|
+
end
|
22
|
+
|
23
|
+
# Fetch a language file.
|
24
|
+
# By default it will make a conditional GET Request, using the `If-Modified-Since` tag.
|
25
|
+
# You can force the method to re-download your file by passing `true` as a second argument
|
26
|
+
#
|
27
|
+
# Example of implementation:
|
28
|
+
#
|
29
|
+
# configuration = WebTranslateIt::Configuration.new
|
30
|
+
# locale = configuration.locales.first
|
31
|
+
# file = configuration.files.first
|
32
|
+
# file.fetch(locale) # the first time, will return the content of the language file with a status 200 OK
|
33
|
+
# file.fetch(locale) # returns nothing, with a status 304 Not Modified
|
34
|
+
# file.fetch(locale, true) # force to re-download the file, will return the content of the file with a 200 OK
|
35
|
+
#
|
36
|
+
def fetch(locale, force = false)
|
37
|
+
WebTranslateIt::Util.http_connection do |http|
|
38
|
+
request = Net::HTTP::Get.new(api_url(locale))
|
39
|
+
request.add_field('If-Modified-Since', last_modification(file_path_for_locale(locale))) if File.exist?(file_path_for_locale(locale)) and !force
|
40
|
+
response = http.request(request)
|
41
|
+
File.open(file_path_for_locale(locale), 'w'){ |file| file << response.body } if response.code.to_i == 200 and response.body != ''
|
42
|
+
response.code.to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Update a language file to Web Translate It by performing a PUT Request.
|
47
|
+
# Note that it is currently not possible to POST a new language file at the moment.
|
48
|
+
#
|
49
|
+
# Example of implementation:
|
50
|
+
#
|
51
|
+
# configuration = WebTranslateIt::Configuration.new
|
52
|
+
# locale = configuration.locales.first
|
53
|
+
# file = configuration.files.first
|
54
|
+
# file.upload(locale) # should respond the HTTP code 202 Accepted
|
55
|
+
#
|
56
|
+
# The meaning of the HTTP 202 code is: the request has been accepted for processing, but the processing has not
|
57
|
+
# been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing
|
58
|
+
# actually takes place.
|
59
|
+
# This is due to the fact that language file imports are handled by background processing.
|
60
|
+
|
61
|
+
def upload(locale)
|
62
|
+
File.open(file_path_for_locale_initial(locale)) do |file|
|
63
|
+
WebTranslateIt::Util.http_connection do |http|
|
64
|
+
request = Net::HTTP::Put::Multipart.new(api_url(locale), "file" => UploadIO.new(file, "text/plain", file.path))
|
65
|
+
response = http.request(request)
|
66
|
+
response.code.to_i
|
67
|
+
end
|
68
|
+
#end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def file_path_for_locale_initial(locale)
|
73
|
+
self.file_path.gsub("[locale]", locale)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Convenience method which returns the file path of a TranslationFile for a given locale.
|
77
|
+
def file_path_for_locale(locale)
|
78
|
+
self.file_path.gsub("[locale].pot", locale.split(/-/, 2)[0].to_s.split(/_/, 2)[0].to_s + "/" + "en.po")
|
79
|
+
end
|
80
|
+
|
81
|
+
def file_path_for_directory(locale)
|
82
|
+
self.file_path.gsub("[locale].pot", locale.split(/-/, 2)[0].to_s.split(/_/, 2)[0].to_s + "/")
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
# Convenience method which returns the date of last modification of a language file.
|
88
|
+
def last_modification(file_path)
|
89
|
+
File.mtime(File.new(file_path, 'r')).rfc2822
|
90
|
+
end
|
91
|
+
|
92
|
+
# Convenience method which returns the URL of the API endpoint for a locale.
|
93
|
+
def api_url(locale)
|
94
|
+
"/api/projects/#{api_key}/files/#{self.id}/locales/#{locale}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module WebTranslateIt
|
2
|
+
|
3
|
+
# A few useful functions
|
4
|
+
class Util
|
5
|
+
|
6
|
+
# Return a string representing the gem version
|
7
|
+
# For example "1.4.4"
|
8
|
+
def self.version
|
9
|
+
hash = YAML.load_file File.join(File.dirname(__FILE__), '..', '..' '/version.yml')
|
10
|
+
[hash[:major], hash[:minor], hash[:patch]].join('.')
|
11
|
+
end
|
12
|
+
|
13
|
+
# Yields a HTTP connection over SSL to Web Translate It.
|
14
|
+
# This is used for the connections to the API throughout the library.
|
15
|
+
# Use it like so:
|
16
|
+
#
|
17
|
+
# WebTranslateIt::Util.http_connection do |http|
|
18
|
+
# request = Net::HTTP::Get.new(api_url)
|
19
|
+
# response = http.request(request)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
def self.http_connection
|
23
|
+
http = Net::HTTP.new('webtranslateit.com', 443)
|
24
|
+
http.use_ssl = true
|
25
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
26
|
+
http.read_timeout = 40
|
27
|
+
yield http
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.calculate_percentage(processed, total)
|
31
|
+
return 0 if total == 0
|
32
|
+
((processed*10)/total).to_f.ceil*10
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'util')
|
2
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'configuration')
|
3
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'translation_file')
|
4
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'auto_fetch')
|
5
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'command_line')
|
6
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'project')
|
7
|
+
require File.join(File.dirname(__FILE__), 'web_translate_it', 'tasks')
|
8
|
+
|
9
|
+
module WebTranslateIt
|
10
|
+
def self.fetch_translations
|
11
|
+
config = Configuration.new
|
12
|
+
locale = I18n.locale.to_s
|
13
|
+
return if config.ignore_locales.include?(locale)
|
14
|
+
config.logger.debug { "Fetching #{locale} translations to Web Translate It" } if config.logger
|
15
|
+
config.files.each do |file|
|
16
|
+
response = file.fetch(locale)
|
17
|
+
config.logger { "Web Translate It response: #{response}" } if config.logger
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/man/wti.1
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
.\" generated with Ronn/v0.4.1
|
2
|
+
.\" http://github.com/rtomayko/ronn/
|
3
|
+
.
|
4
|
+
.TH "WTI" "1" "March 2010" "Atelier Convivialité" "Web Translate It"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBwti\fR \-\- WebTranslateIt.com from the command line
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBwti\fR \fICOMMAND\fR \fIOPTIONS\fR
|
11
|
+
.
|
12
|
+
.P
|
13
|
+
\fBwti push\fR [\fB\-l\fR] \fIOPTIONS\fR
|
14
|
+
.
|
15
|
+
.P
|
16
|
+
\fBwti pull\fR [\fB\-l\fR] \fIOPTIONS\fR
|
17
|
+
.
|
18
|
+
.SH "DESCRIPTION"
|
19
|
+
\fBwti\fR is an utility to help you sync language files between the
|
20
|
+
WebTranslateIt.com service and your computer/server.
|
21
|
+
.
|
22
|
+
.P
|
23
|
+
\fBwti push\fR will push your master language file to Web Translate It. It means it will
|
24
|
+
update the strings hosted at Web Translate It by the strings from the file you push.
|
25
|
+
.
|
26
|
+
.P
|
27
|
+
\fBwti pull\fR will pull the target language files from Web Translate It. It will download
|
28
|
+
and update your file with the latest translations from Web Translate It.
|
29
|
+
.
|
30
|
+
.P
|
31
|
+
\fBwti stats\fR fetch and display translation statistics from Web Translate It.
|
32
|
+
.
|
33
|
+
.SH "OPTIONS"
|
34
|
+
\fBwti\fR's default mode of operation is to push only the master language file and to only
|
35
|
+
pull target language files.
|
36
|
+
.
|
37
|
+
.P
|
38
|
+
These options can be used to change this behaviour:
|
39
|
+
.
|
40
|
+
.TP
|
41
|
+
\fB\-\-all\fR
|
42
|
+
Push or pull all. For example, \fBwti push \-\-all\fR will push master and target language files. \fBwti pull \-\-all\fR will pull master and target language files
|
43
|
+
.
|
44
|
+
.TP
|
45
|
+
\fB\-l\fR, \fB\-\-locale\fR
|
46
|
+
Set the locale to push or pull explicitly. For example \fBwti pull \-l fr\fR will only pull
|
47
|
+
the French language file.
|
48
|
+
.
|
49
|
+
.TP
|
50
|
+
\fB\-\-force\fR
|
51
|
+
The Web Translate It API use HTTP caching to be efficient, and check if your file needs
|
52
|
+
to be updated by checking its modification date against the project’s latest activity.
|
53
|
+
Use this option to bypass this check.
|
54
|
+
.
|
55
|
+
.P
|
56
|
+
You may additionally ask for help:
|
57
|
+
.
|
58
|
+
.TP
|
59
|
+
\fB\-h\fR, \fB\-\-help\fR
|
60
|
+
Print help.
|
61
|
+
.
|
62
|
+
.SH "CONFIGURATION"
|
63
|
+
The first \fBwti\fR is used on a project, it must be configured.
|
64
|
+
.
|
65
|
+
.P
|
66
|
+
\fBwti autoconf\fR will help you create a configuration file to sync with
|
67
|
+
Web Translate It.
|
68
|
+
.
|
69
|
+
.SH "EXAMPLES"
|
70
|
+
.
|
71
|
+
.nf
|
72
|
+
$ wti push
|
73
|
+
Pushing ./config/locales/app/en.yml…
|
74
|
+
Pushing ./config/locales/defaults/en.yml…
|
75
|
+
$ wti pull \-l fr
|
76
|
+
Pulling ./config/locales/app/fr.yml…
|
77
|
+
Pulling ./config/locales/defaults/fr.yml…
|
78
|
+
$ wti stats
|
79
|
+
fr: 100% translated, 90% completed
|
80
|
+
ru: 10% translated, 10% completed
|
81
|
+
pt_BR: 0% translated, 0% completed
|
82
|
+
en: 100% translated, 90% completed
|
83
|
+
.
|
84
|
+
.fi
|
85
|
+
.
|
86
|
+
.SH "BUGS"
|
87
|
+
\fIhttp://github.com/atelierConvivialite/webtranslateit/issues\fR
|
88
|
+
.
|
89
|
+
.SH "AUTHOR"
|
90
|
+
Édouard Brière :: edouard@atelierconvivialite.com
|
data/man/wti.1.html
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
5
|
+
<meta name='generator' value='Ronn/v0.4.1'>
|
6
|
+
<title>wti(1) -- WebTranslateIt.com from the command line</title>
|
7
|
+
<style type='text/css'>
|
8
|
+
body {margin:0}
|
9
|
+
#man, #man code, #man pre, #man tt, #man kbd, #man samp {
|
10
|
+
font-family:consolas,monospace;
|
11
|
+
font-size:16px;
|
12
|
+
line-height:1.3;
|
13
|
+
color:#343331;
|
14
|
+
background:#fff; }
|
15
|
+
#man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
|
16
|
+
#man h1, #man h2, #man h3 { color:#232221;clear:left }
|
17
|
+
#man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
|
18
|
+
#man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
|
19
|
+
#man h3 { font-size:16px; margin:0 0 0 4ex; }
|
20
|
+
#man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
|
21
|
+
#man pre {
|
22
|
+
color:#333231;
|
23
|
+
background:#edeceb;
|
24
|
+
padding:5px 7px;
|
25
|
+
margin:0px 0 20px 0;
|
26
|
+
border-left:2ex solid #ddd}
|
27
|
+
#man pre + h2, #man pre + h3 {
|
28
|
+
margin-top:22px;
|
29
|
+
}
|
30
|
+
#man h2 + pre, #man h3 + pre {
|
31
|
+
margin-top:5px;
|
32
|
+
}
|
33
|
+
#man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
|
34
|
+
#man dt { margin:0; clear:left }
|
35
|
+
#man dt.flush { float:left; width:8ex }
|
36
|
+
#man dd { margin:0 0 0 9ex }
|
37
|
+
#man code, #man strong, #man b { font-weight:bold; color:#131211; }
|
38
|
+
#man pre code { font-weight:normal; color:#232221; background:inherit }
|
39
|
+
#man em, var, u {
|
40
|
+
font-style:normal; color:#333231; border-bottom:1px solid #999; }
|
41
|
+
#man h1.man-title { display:none; }
|
42
|
+
#man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
|
43
|
+
float:left; width:33%; list-style-type:none;
|
44
|
+
text-transform:uppercase; font-size:18px; color:#999;
|
45
|
+
letter-spacing:1px;}
|
46
|
+
#man ol.man { width:100%; }
|
47
|
+
#man ol.man li.tl { text-align:left }
|
48
|
+
#man ol.man li.tc { text-align:center;letter-spacing:4px }
|
49
|
+
#man ol.man li.tr { text-align:right }
|
50
|
+
#man ol.man a { color:#999 }
|
51
|
+
#man ol.man a:hover { color:#333231 }
|
52
|
+
</style>
|
53
|
+
</head>
|
54
|
+
<body>
|
55
|
+
<div id='man'>
|
56
|
+
|
57
|
+
<h1 class='man-title'>wti(1)</h1>
|
58
|
+
|
59
|
+
<ol class='head man'>
|
60
|
+
<li class='tl'>wti(1)</li>
|
61
|
+
<li class='tc'>Web Translate It</li>
|
62
|
+
<li class='tr'>wti(1)</li>
|
63
|
+
</ol>
|
64
|
+
|
65
|
+
<h2 id='NAME'>NAME</h2>
|
66
|
+
<p><code>wti</code> -- WebTranslateIt.com from the command line</p>
|
67
|
+
|
68
|
+
<h2>SYNOPSIS</h2>
|
69
|
+
|
70
|
+
<p><code>wti</code> <var>COMMAND</var> <var>OPTIONS</var></p>
|
71
|
+
|
72
|
+
<p><code>wti push</code> [<code>-l</code>] <var>OPTIONS</var></p>
|
73
|
+
|
74
|
+
<p><code>wti pull</code> [<code>-l</code>] <var>OPTIONS</var></p>
|
75
|
+
|
76
|
+
<h2>DESCRIPTION</h2>
|
77
|
+
|
78
|
+
<p><code>wti</code> is an utility to help you sync language files between the
|
79
|
+
WebTranslateIt.com service and your computer/server.</p>
|
80
|
+
|
81
|
+
<p><code>wti push</code> will push your master language file to Web Translate It. It means it will
|
82
|
+
update the strings hosted at Web Translate It by the strings from the file you push.</p>
|
83
|
+
|
84
|
+
<p><code>wti pull</code> will pull the target language files from Web Translate It. It will download
|
85
|
+
and update your file with the latest translations from Web Translate It.</p>
|
86
|
+
|
87
|
+
<p><code>wti stats</code> fetch and display translation statistics from Web Translate It.</p>
|
88
|
+
|
89
|
+
<h2>OPTIONS</h2>
|
90
|
+
|
91
|
+
<p><code>wti</code>'s default mode of operation is to push only the master language file and to only
|
92
|
+
pull target language files.</p>
|
93
|
+
|
94
|
+
<p>These options can be used to change this behaviour:</p>
|
95
|
+
|
96
|
+
<dl>
|
97
|
+
<dt class="flush"><code>--all</code></dt><dd><p>Push or pull all. For example, <code>wti push --all</code> will push master and target language files.
|
98
|
+
<code>wti pull --all</code> will pull master and target language files</p></dd>
|
99
|
+
<dt><code>-l</code>, <code>--locale</code></dt><dd><p>Set the locale to push or pull explicitly. For example <code>wti pull -l fr</code> will only pull
|
100
|
+
the French language file.</p></dd>
|
101
|
+
<dt class="flush"><code>--force</code></dt><dd><p>The Web Translate It API use HTTP caching to be efficient, and check if your file needs
|
102
|
+
to be updated by checking its modification date against the project’s latest activity.
|
103
|
+
Use this option to bypass this check.</p></dd>
|
104
|
+
</dl>
|
105
|
+
|
106
|
+
|
107
|
+
<p>You may additionally ask for help:</p>
|
108
|
+
|
109
|
+
<dl>
|
110
|
+
<dt><code>-h</code>, <code>--help</code></dt><dd>Print help.</dd>
|
111
|
+
</dl>
|
112
|
+
|
113
|
+
|
114
|
+
<h2>CONFIGURATION</h2>
|
115
|
+
|
116
|
+
<p>The first <code>wti</code> is used on a project, it must be configured.</p>
|
117
|
+
|
118
|
+
<p><code>wti autoconf</code> will help you create a configuration file to sync with
|
119
|
+
Web Translate It.</p>
|
120
|
+
|
121
|
+
<h2>EXAMPLES</h2>
|
122
|
+
|
123
|
+
<pre><code>$ wti push
|
124
|
+
Pushing ./config/locales/app/en.yml…
|
125
|
+
Pushing ./config/locales/defaults/en.yml…
|
126
|
+
|
127
|
+
|
128
|
+
$ wti pull -l fr
|
129
|
+
Pulling ./config/locales/app/fr.yml…
|
130
|
+
Pulling ./config/locales/defaults/fr.yml…
|
131
|
+
|
132
|
+
|
133
|
+
$ wti stats
|
134
|
+
fr: 100% translated, 90% completed
|
135
|
+
ru: 10% translated, 10% completed
|
136
|
+
pt_BR: 0% translated, 0% completed
|
137
|
+
en: 100% translated, 90% completed
|
138
|
+
</code></pre>
|
139
|
+
|
140
|
+
<h2>BUGS</h2>
|
141
|
+
|
142
|
+
<p><a href="http://github.com/atelierConvivialite/webtranslateit/issues">http://github.com/atelierConvivialite/webtranslateit/issues</a></p>
|
143
|
+
|
144
|
+
<h2>AUTHOR</h2>
|
145
|
+
|
146
|
+
<p>Édouard Brière :: edouard@atelierconvivialite.com</p>
|
147
|
+
|
148
|
+
|
149
|
+
<ol class='foot man'>
|
150
|
+
<li class='tl'>Atelier Convivialité</li>
|
151
|
+
<li class='tc'>March 2010</li>
|
152
|
+
<li class='tr'>wti(1)</li>
|
153
|
+
</ol>
|
154
|
+
|
155
|
+
</div>
|
156
|
+
</body>
|
157
|
+
</html>
|
data/man/wti.1.ron
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
wti(1) -- WebTranslateIt.com from the command line
|
2
|
+
==================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
`wti` <COMMAND> <OPTIONS>
|
7
|
+
|
8
|
+
`wti push` [`-l`] <OPTIONS>
|
9
|
+
|
10
|
+
`wti pull` [`-l`] <OPTIONS>
|
11
|
+
|
12
|
+
## DESCRIPTION
|
13
|
+
|
14
|
+
`wti` is an utility to help you sync language files between the
|
15
|
+
WebTranslateIt.com service and your computer/server.
|
16
|
+
|
17
|
+
`wti push` will push your master language file to Web Translate It. It means it will
|
18
|
+
update the strings hosted at Web Translate It by the strings from the file you push.
|
19
|
+
|
20
|
+
`wti pull` will pull the target language files from Web Translate It. It will download
|
21
|
+
and update your file with the latest translations from Web Translate It.
|
22
|
+
|
23
|
+
`wti stats` fetch and display translation statistics from Web Translate It.
|
24
|
+
|
25
|
+
## OPTIONS
|
26
|
+
|
27
|
+
`wti`'s default mode of operation is to push only the master language file and to only
|
28
|
+
pull target language files.
|
29
|
+
|
30
|
+
These options can be used to change this behaviour:
|
31
|
+
|
32
|
+
* `--all`:
|
33
|
+
Push or pull all. For example, `wti push --all` will push master and target language files.
|
34
|
+
`wti pull --all` will pull master and target language files
|
35
|
+
|
36
|
+
* `-l`, `--locale`:
|
37
|
+
Set the locale to push or pull explicitly. For example `wti pull -l fr` will only pull
|
38
|
+
the French language file.
|
39
|
+
|
40
|
+
* `--force`:
|
41
|
+
The Web Translate It API use HTTP caching to be efficient, and check if your file needs
|
42
|
+
to be updated by checking its modification date against the project’s latest activity.
|
43
|
+
Use this option to bypass this check.
|
44
|
+
|
45
|
+
You may additionally ask for help:
|
46
|
+
|
47
|
+
* `-h`, `--help`:
|
48
|
+
Print help.
|
49
|
+
|
50
|
+
## CONFIGURATION
|
51
|
+
|
52
|
+
The first `wti` is used on a project, it must be configured.
|
53
|
+
|
54
|
+
`wti autoconf` will help you create a configuration file to sync with
|
55
|
+
Web Translate It.
|
56
|
+
|
57
|
+
## EXAMPLES
|
58
|
+
|
59
|
+
$ wti push
|
60
|
+
Pushing ./config/locales/app/en.yml…
|
61
|
+
Pushing ./config/locales/defaults/en.yml…
|
62
|
+
|
63
|
+
|
64
|
+
$ wti pull -l fr
|
65
|
+
Pulling ./config/locales/app/fr.yml…
|
66
|
+
Pulling ./config/locales/defaults/fr.yml…
|
67
|
+
|
68
|
+
|
69
|
+
$ wti stats
|
70
|
+
fr: 100% translated, 90% completed
|
71
|
+
ru: 10% translated, 10% completed
|
72
|
+
pt_BR: 0% translated, 0% completed
|
73
|
+
en: 100% translated, 90% completed
|
74
|
+
|
75
|
+
## BUGS
|
76
|
+
|
77
|
+
<http://github.com/atelierConvivialite/webtranslateit/issues>
|
78
|
+
|
79
|
+
## AUTHOR
|
80
|
+
|
81
|
+
Édouard Brière :: edouard@atelierconvivialite.com
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# The Project API Token from Web Translate It
|
2
|
+
api_key: abcd
|
3
|
+
|
4
|
+
# The Master locale is the locale you translate your project from. Web Translate It shouldn’t
|
5
|
+
# attempt to edit these files.
|
6
|
+
ignore_locales: en_GB
|
7
|
+
|
8
|
+
# A list of files to translate
|
9
|
+
# You can name your language files as you want, as long as the locale name match the
|
10
|
+
# locale name you set in Web Translate It, and that the different language files names are
|
11
|
+
# differenciated by their locale name.
|
12
|
+
# For example, if you set to translate a project in en_US in WTI, you should use the locale en_US in your app
|
13
|
+
files:
|
14
|
+
- config/locales/file1_[locale].yml
|
15
|
+
- config/locales/file2_[locale].yml
|
@@ -0,0 +1,38 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
templates:
|
5
|
+
header:
|
6
|
+
one: "1 error prohibited this {{model}} from being saved"
|
7
|
+
other: "{{count}} errors prohibited this {{model}} from being saved"
|
8
|
+
body: "there were problems with the following fields:"
|
9
|
+
messages:
|
10
|
+
accepted: "must be accepted"
|
11
|
+
blank: "can't be blank"
|
12
|
+
confirmation: "doesn't match confirmation"
|
13
|
+
empty: "can't be empty"
|
14
|
+
equal_to: "must be equal to {{count}}"
|
15
|
+
even: "must be even"
|
16
|
+
exclusion: "is reserved"
|
17
|
+
greater_than: "must be greater than {{count}}"
|
18
|
+
greater_than_or_equal_to: "must be greater than or equal to {{count}}"
|
19
|
+
inclusion: "is not included in the list"
|
20
|
+
invalid: "is invalid"
|
21
|
+
less_than: "must be less than {{count}}"
|
22
|
+
less_than_or_equal_to: "must be less than or equal to {{count}}"
|
23
|
+
not_a_number: "is not a number"
|
24
|
+
odd: "must be odd"
|
25
|
+
taken: "is already taken"
|
26
|
+
too_long: "is too long (maximum is {{count}} characters)"
|
27
|
+
too_short: "is too short (minimum is {{count}} characters)"
|
28
|
+
wrong_length: "is the wrong length (should be {{count}} characters)"
|
29
|
+
models:
|
30
|
+
invitation:
|
31
|
+
attributes:
|
32
|
+
email:
|
33
|
+
user_already_invited: "This user has already been invited"
|
34
|
+
user_already_member: "This user is already a member"
|
35
|
+
project_file:
|
36
|
+
attributes:
|
37
|
+
file:
|
38
|
+
file_format_not_supported: "Sorry, we currenly support only Gettext .pot/.po, .yml/.yaml and .strings"
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe WebTranslateIt::Configuration do
|
4
|
+
before(:each) do
|
5
|
+
WebTranslateIt::Configuration.const_set("RAILS_ROOT", File.dirname(__FILE__) + '/../examples')
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
it "should fetch and not blow up" do
|
10
|
+
lambda{ WebTranslateIt::Configuration.new }.should_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should load the content of the YAML file" do
|
14
|
+
config_hash = {
|
15
|
+
"api_key" => "abcd",
|
16
|
+
"ignore_locales" => "en_GB",
|
17
|
+
"files" => ["config/locales/file1_[locale].yml", "config/locales/file2_[locale].yml"]
|
18
|
+
}
|
19
|
+
YAML.should_receive(:load_file).and_return(config_hash)
|
20
|
+
WebTranslateIt::Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should assign the API key, autofetch, files and master_locale" do
|
24
|
+
configuration = WebTranslateIt::Configuration.new
|
25
|
+
configuration.api_key.should == 'abcd'
|
26
|
+
configuration.files.first.should be_a(WebTranslateIt::TranslationFile)
|
27
|
+
configuration.ignore_locales.should == ['en_GB']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|