zwr 0.0.2 → 0.0.3
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/lib/tasks/loc.rake +10 -5
- data/lib/zwr/railtie.rb +6 -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: 663b35616f5630708c1c89d3067fcf966687cbe2
|
4
|
+
data.tar.gz: 2f85fc35932ba3ecbf2e131bba85a7f8680131fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd4b7ae9cd83c2308fe82395fbb4f4ae6a0f203fe42e8bd45d7e6ae0434df40ddc16fa0418794f68106d056220bd22b4d54cd80738f755908073ff9f3a3b35a
|
7
|
+
data.tar.gz: ac84313d303bf526c95bf1a155fb3c128cbcc61d32ba57fa2cb4d97c6ac4b9ebeac2793ceaf09893b272d52189cd3ce14f68cc1a6875b292d071f439567c868c
|
data/lib/tasks/loc.rake
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
namespace :loc do
|
2
|
-
def extract_from(folder)
|
2
|
+
def extract_from(folder, list)
|
3
3
|
Dir.entries(folder).each do |fof|
|
4
4
|
if File.directory?(fof_full = File.join(folder,fof)) and fof !='.' and fof != '..'
|
5
|
-
extract_from fof_full
|
5
|
+
extract_from fof_full, list
|
6
6
|
else
|
7
7
|
if File.extname(fof_full) == ".haml"
|
8
8
|
File.open(fof_full).read().scan(/=t :'(.+)'(\s*#\s*(.+))?/) do |match|
|
9
|
-
sym = match[0]
|
10
|
-
|
9
|
+
sym = match[0]
|
10
|
+
# Do not add multiple items, even if default translation (as comment) differs
|
11
|
+
if list.none? { |x| x[0] == sym }
|
12
|
+
list << [sym, %{ "#{sym}":}.ljust(30) + %{"#{match[2] || match[0]}"}]
|
13
|
+
end
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -16,6 +19,8 @@ namespace :loc do
|
|
16
19
|
|
17
20
|
desc "extracts all localized strings from all HAML files"
|
18
21
|
task :extract do
|
19
|
-
|
22
|
+
list = []
|
23
|
+
extract_from Rails.root, list
|
24
|
+
list.each { |x| puts x[1] }
|
20
25
|
end
|
21
26
|
end
|
data/lib/zwr/railtie.rb
CHANGED
@@ -7,7 +7,12 @@ module Zwr
|
|
7
7
|
rake_tasks do
|
8
8
|
load "tasks/loc.rake"
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
# Following will allow us to use something like the following
|
12
|
+
# also in the javascript HAML templates:
|
13
|
+
#
|
14
|
+
# %span=t :'zeljko'
|
15
|
+
#
|
11
16
|
Sprockets::Context.send :include, ActionView::Helpers::TranslationHelper
|
12
17
|
end
|
13
18
|
end
|