threedaymonk-l10nizer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +50 -0
- data/Rakefile +1 -1
- data/lib/l10nizer/node.rb +1 -1
- data/lib/l10nizer/version.rb +1 -1
- data/test/test_processor.rb +2 -2
- metadata +4 -3
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
L10nizer
|
2
|
+
========
|
3
|
+
|
4
|
+
Automagic _ex post facto_ localisation for Rails templates.
|
5
|
+
|
6
|
+
What it does
|
7
|
+
------------
|
8
|
+
|
9
|
+
Processes all your `html.erb` templates, extracts text, replaces it with `t()` calls, and generates a YAML file of localisations.
|
10
|
+
|
11
|
+
For example, given a file `app/views/things/show.html.erb` with this content:
|
12
|
+
|
13
|
+
<div class="thing">
|
14
|
+
<h1>Some heading</h1>
|
15
|
+
<p>This thing is called <%= h(@thing.name)</p>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
l10nizer will change it to:
|
19
|
+
|
20
|
+
<div class="thing">
|
21
|
+
<h1><%= t("things.some_heading") %></h1>
|
22
|
+
<p><%= t("things.this_thing_is_called_a", :a => (h(@thing.name))) %></p>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
and generate the following entries in `config/locales/l10nized.yml`:
|
26
|
+
|
27
|
+
things:
|
28
|
+
some_heading: Some heading
|
29
|
+
this_thing_is_called_a: This thing is called {{a}}
|
30
|
+
|
31
|
+
You can then use `l10nized.yml` as a basis for the localisation file for your current locale, e.g. `en_GB.yml`.
|
32
|
+
|
33
|
+
Usage
|
34
|
+
-----
|
35
|
+
|
36
|
+
From within a Rails application directory:
|
37
|
+
|
38
|
+
l10nizer
|
39
|
+
|
40
|
+
Specifying the application path explicitly:
|
41
|
+
|
42
|
+
l10nizer /path/to/my/rails/app
|
43
|
+
|
44
|
+
Limitations
|
45
|
+
-----------
|
46
|
+
|
47
|
+
* Perhaps ironically for a _localisation_ utility, l10nizer assumes that your templates are written in English or generally in ASCII, and ignores non-alphanumeric content when generating localisation keys. This could be fixed by modifying or replacing the L10nizer::KeyGenerator class.
|
48
|
+
* L10nizer takes no position on HTML entities or escaping. You __will__ need to review the changes it makes.
|
49
|
+
* Similarly, pluralisation is outside the scope of this application and will require attention.
|
50
|
+
* Strings that should be single entities but which contain HTML will be broken into multiple localisation strings.
|
data/Rakefile
CHANGED
@@ -29,7 +29,7 @@ spec = Gem::Specification.new do |s|
|
|
29
29
|
|
30
30
|
s.has_rdoc = false
|
31
31
|
|
32
|
-
s.files = %w(Rakefile) + Dir.glob("{bin,test,lib}/**/*")
|
32
|
+
s.files = %w(Rakefile README.md) + Dir.glob("{bin,test,lib}/**/*")
|
33
33
|
s.executables = FileList["bin/**"].map { |f| File.basename(f) }
|
34
34
|
|
35
35
|
s.require_paths = ["lib"]
|
data/lib/l10nizer/node.rb
CHANGED
data/lib/l10nizer/version.rb
CHANGED
data/test/test_processor.rb
CHANGED
@@ -36,7 +36,7 @@ class ProcessorTest < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
|
38
38
|
should "pass values to t()" do
|
39
|
-
expected = %{<%= t("string_a_with_b", :a => 27, :b => 42) %>}
|
39
|
+
expected = %{<%= t("string_a_with_b", :a => (27), :b => (42)) %>}
|
40
40
|
assert_equal expected, @l10nizer.reformed
|
41
41
|
end
|
42
42
|
|
@@ -53,7 +53,7 @@ class ProcessorTest < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
should "pass values to t() reusing placeholder variables" do
|
56
|
-
expected = %{<p><%= t("string_a_with_b", :a => 27, :b => 42) %></p><p><%= t("another_a", :a => 'x') %></p>}
|
56
|
+
expected = %{<p><%= t("string_a_with_b", :a => (27), :b => (42)) %></p><p><%= t("another_a", :a => ('x')) %></p>}
|
57
57
|
assert_equal expected, @l10nizer.reformed
|
58
58
|
end
|
59
59
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: threedaymonk-l10nizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Battley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-13 00:00:00 -07:00
|
13
13
|
default_executable: l10nizer
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,7 @@ extra_rdoc_files: []
|
|
52
52
|
|
53
53
|
files:
|
54
54
|
- Rakefile
|
55
|
+
- README.md
|
55
56
|
- bin/l10nizer
|
56
57
|
- test/samples
|
57
58
|
- test/samples/input.html.erb
|
@@ -90,7 +91,7 @@ requirements: []
|
|
90
91
|
rubyforge_project:
|
91
92
|
rubygems_version: 1.2.0
|
92
93
|
signing_key:
|
93
|
-
specification_version:
|
94
|
+
specification_version: 3
|
94
95
|
summary: Automatically extract strings from ERB templates and replace with calls to t()
|
95
96
|
test_files: []
|
96
97
|
|