ymdp 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ymdp/compiler/base.rb +8 -7
- data/lib/ymdp/compiler/template.rb +82 -0
- data/lib/ymdp/javascripts/jquery/i18n.js +2 -25
- data/lib/ymdp/javascripts/jquery/user.js.coffee +4 -1
- data/lib/ymdp/view/application_view.rb +10 -11
- data/ymdp.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/ymdp/compiler/base.rb
CHANGED
@@ -57,7 +57,7 @@ module YMDP
|
|
57
57
|
["views", "assets"].each do |dir|
|
58
58
|
process_path("#{base_path}/app/#{dir}/")
|
59
59
|
end
|
60
|
-
process_all_translations
|
60
|
+
# process_all_translations
|
61
61
|
copy_config_files
|
62
62
|
copy_images
|
63
63
|
end
|
@@ -156,13 +156,14 @@ module YMDP
|
|
156
156
|
|
157
157
|
# Concatenate together all the YRB ".pres" files for this language into one file in the tmp dir.
|
158
158
|
#
|
159
|
-
F.concat_files("#{yrb_path}/#{lang}/*", tmp_file)
|
159
|
+
# F.concat_files("#{yrb_path}/#{lang}/*", tmp_file)
|
160
160
|
|
161
|
-
yrb = YMDP::Compiler::Template::YRB.new(:file => tmp_file, :domain => domain)
|
162
|
-
yrb.
|
163
|
-
yrb.
|
161
|
+
# yrb = YMDP::Compiler::Template::YRB.new(:file => tmp_file, :domain => domain)
|
162
|
+
# yrb = YMDP::Compiler::Template::Yaml.new(:file => tmp_file, :domain => domain)
|
163
|
+
# yrb.build
|
164
|
+
# yrb.validate if CONFIG.validate_json_assets?
|
164
165
|
|
165
|
-
FileUtils.rm(tmp_file)
|
166
|
+
# FileUtils.rm(tmp_file)
|
166
167
|
end
|
167
168
|
|
168
169
|
# Creates a fresh destination directory structure for the code to be compiled into.
|
@@ -256,7 +257,7 @@ module YMDP
|
|
256
257
|
end
|
257
258
|
|
258
259
|
def yrb_path
|
259
|
-
"#{
|
260
|
+
"#{config_path}/locales"
|
260
261
|
end
|
261
262
|
|
262
263
|
def images_path
|
@@ -339,6 +339,88 @@ module YMDP
|
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
|
+
# Process YAML format translation files.
|
343
|
+
#
|
344
|
+
# Convert them to a hash and write the hash to a JSON file.
|
345
|
+
#
|
346
|
+
# Each language can have as many YAML translation files as necessary.
|
347
|
+
# The files are converted into a single JSON file for each language.
|
348
|
+
#
|
349
|
+
class Yaml < Base
|
350
|
+
# Base directory for translations for this domain.
|
351
|
+
#
|
352
|
+
def directory
|
353
|
+
directory = "#{paths[:base_path]}/servers/#{@domain}/assets/yrb"
|
354
|
+
FileUtils.mkdir_p(directory)
|
355
|
+
directory
|
356
|
+
end
|
357
|
+
|
358
|
+
# The destination of the compiled JSON file.
|
359
|
+
#
|
360
|
+
def destination_path
|
361
|
+
filename = convert_filename(@file.split("/").last)
|
362
|
+
"#{directory}/#{filename}"
|
363
|
+
end
|
364
|
+
|
365
|
+
# JSON values of the compiled translations.
|
366
|
+
#
|
367
|
+
def to_json
|
368
|
+
processed_template
|
369
|
+
end
|
370
|
+
|
371
|
+
# Turn it back into a hash.
|
372
|
+
#
|
373
|
+
def to_hash
|
374
|
+
yaml
|
375
|
+
end
|
376
|
+
|
377
|
+
# Parse Yaml file
|
378
|
+
#
|
379
|
+
def yaml
|
380
|
+
@yaml ||= ::YAML.load_file(@file)
|
381
|
+
end
|
382
|
+
|
383
|
+
# Convert the hash to Yaml if you should want to do that.
|
384
|
+
#
|
385
|
+
def to_yaml
|
386
|
+
to_hash.to_yaml
|
387
|
+
end
|
388
|
+
|
389
|
+
# This function is the file which is written to the destination--in this
|
390
|
+
# case, the JSON file.
|
391
|
+
#
|
392
|
+
def processed_template
|
393
|
+
yaml.to_json
|
394
|
+
end
|
395
|
+
|
396
|
+
# Validate the JSON file.
|
397
|
+
#
|
398
|
+
def validate
|
399
|
+
Epic::Validator::JSON.new.validate(destination_path)
|
400
|
+
end
|
401
|
+
|
402
|
+
private
|
403
|
+
|
404
|
+
# Strip off the extension from original Yaml files.
|
405
|
+
#
|
406
|
+
def base_filename(filename)
|
407
|
+
filename.gsub(/\.yaml/, "")
|
408
|
+
end
|
409
|
+
|
410
|
+
# Take the base filename and add the ".json" extension.
|
411
|
+
#
|
412
|
+
def convert_filename(filename)
|
413
|
+
"#{base_filename(filename)}.json"
|
414
|
+
end
|
415
|
+
|
416
|
+
# Write JSON file to its destination.
|
417
|
+
#
|
418
|
+
def write_template(result)
|
419
|
+
$stdout.puts destination_path if CONFIG.verbose?
|
420
|
+
write_template_without_layout(result)
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
342
424
|
# Process Yahoo! Resource Bundle format translation files.
|
343
425
|
#
|
344
426
|
# Convert them to a hash and write the hash to a JSON file.
|
@@ -32,16 +32,7 @@ I18n.init = function() {
|
|
32
32
|
};
|
33
33
|
|
34
34
|
I18n.setResources = function() {
|
35
|
-
|
36
|
-
|
37
|
-
Debug.log("begin I18n.setResources for language " + I18n.currentLanguage);
|
38
|
-
asset_path = "<%= @assets_directory %>/yrb/";
|
39
|
-
I18n.keys = OpenMailIntl.getResources(asset_path, "keys", I18n.currentLanguage) || {};
|
40
|
-
if (I18n.currentLanguage !== "en-US") {
|
41
|
-
I18n.default_keys = OpenMailIntl.getResources(asset_path, "keys", "en-US") || {};
|
42
|
-
} else {
|
43
|
-
I18n.default_keys = I18n.keys;
|
44
|
-
}
|
35
|
+
I18n.keys = <%= translations.to_json %>;
|
45
36
|
};
|
46
37
|
|
47
38
|
I18n.english = function() {
|
@@ -52,17 +43,6 @@ I18n.translate_element = function(element) {
|
|
52
43
|
element = $(element);
|
53
44
|
|
54
45
|
var e;
|
55
|
-
//
|
56
|
-
// e = element.inspect();
|
57
|
-
// if (e.match(/<input/)) {
|
58
|
-
// I18n.v(element.attr("id"));
|
59
|
-
// } else {
|
60
|
-
// if (e.match(/<img/)) {
|
61
|
-
// I18n.src(element.attr("id"));
|
62
|
-
// } else {
|
63
|
-
// I18n.u(element.attr("id");
|
64
|
-
// }
|
65
|
-
// }
|
66
46
|
I18n.u(element.attr("id"));
|
67
47
|
};
|
68
48
|
|
@@ -83,16 +63,13 @@ I18n.translate = function(key, args) {
|
|
83
63
|
} else
|
84
64
|
{
|
85
65
|
m = I18n.translate_phrase(key);
|
86
|
-
if (!m) {
|
87
|
-
m = I18n.default_keys[key];
|
88
|
-
}
|
89
66
|
}
|
90
67
|
return m;
|
91
68
|
};
|
92
69
|
I18n.t = I18n.translate;
|
93
70
|
|
94
71
|
I18n.translate_phrase = function(key) {
|
95
|
-
return I18n["keys"][key];
|
72
|
+
return I18n["keys"][I18n.currentLanguage][key];
|
96
73
|
};
|
97
74
|
|
98
75
|
I18n.translate_sentence = function(key, args) {
|
@@ -137,7 +137,10 @@ window.User =
|
|
137
137
|
|
138
138
|
Debug.log("YMDP.ymail_wssid is defined", YMDP.ymail_wssid)
|
139
139
|
|
140
|
-
|
140
|
+
try
|
141
|
+
success_function(YMDP.ymail_wssid)
|
142
|
+
catch wtf
|
143
|
+
Debug.log wtf
|
141
144
|
|
142
145
|
# gets the guid from the Yahoo! environment and executes the success callback
|
143
146
|
# if there is a guid, and the error callback if it's undefined
|
@@ -18,19 +18,18 @@ module YMDP
|
|
18
18
|
# # => ["en-US", "de-DE", "es-ES", "es-MX"]
|
19
19
|
#
|
20
20
|
def supported_languages
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
dirs.unshift(dirs.delete("en-US"))
|
28
|
-
|
29
|
-
raise "Default YRB key en-US not found" unless dirs.include?("en-US")
|
21
|
+
YAML.load_file("./config/idiom.yml")["locales"].keys
|
22
|
+
end
|
23
|
+
|
24
|
+
def translations
|
25
|
+
@translations ||= {}
|
30
26
|
|
31
|
-
|
27
|
+
Dir["./config/locales/**/*.yml"].each do |file|
|
28
|
+
@translations.merge!(YAML.load_file(file))
|
29
|
+
end
|
30
|
+
@translations
|
32
31
|
end
|
33
|
-
|
32
|
+
|
34
33
|
# Returns an array of country codes of English-speaking countries supported
|
35
34
|
# by the application, based on the language-specific folders located in "app/assets/yrb".
|
36
35
|
#
|
data/ymdp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ymdp"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Isaac Priestley"]
|
12
|
-
s.date = "2012-05-
|
12
|
+
s.date = "2012-05-24"
|
13
13
|
s.description = "Framework for developing applications in the Yahoo! Mail Development Platform."
|
14
14
|
s.email = "progressions@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ymdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Isaac Priestley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|