Skip to content

Commit

Permalink
Enabled [select] without 'show' (default translation from values).
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Feb 2, 2012
1 parent 20a16e7 commit 77455e8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Better Acl display, comments on relations.
* Support for 'to_date' on time object with proper timezone translation. <===== TODO: Document
* Time to 'year' should use timezone.
* Added tprefix to [select] (with default value) to ease translated options for select. <===== TODO: Document

== 1.1.3 2011-11-09

Expand Down
10 changes: 10 additions & 0 deletions lib/zena/use/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,16 @@ def get_options_for_select
show_values = show.split(',').map(&:strip)
elsif show = @params[:tshow]
show_values = translate_list(show)
else
tprefix = @params[:tprefix] || @params[:name]
show_values = options_list.map do |v|
t = trans("#{tprefix}_#{v}")
if t == "#{tprefix}_"
''
else
t
end
end
end

if show_values
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/files/translations_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ translations:
not_found: sans
crop: rogner
no_parent: pas de parent
admin_interface: interface admin
admin_interface: interface admin
# Used to test options list in [select].
assigned_: '--'
assigned_1: foo
assigned_2: bar
assigned_3: baz
9 changes: 8 additions & 1 deletion test/integration/zafu_compiler/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,11 @@ should_show_fields_for_columns:
node: 'forest_pdf'
src: "<r:form><r:Document do='column(\"size\")' do='input'/></r:form>"
tem: "/input type='text' name='node\\[<%= var2.name %>\\]/"
res: "/<input type='text' name='node\\[size\\]' value='63569'/>/"
res: "/<input type='text' name='node\\[size\\]' value='63569'/>/"

should_show_fields_for_columns:
context:
lang: 'fr'
src: "<r:load dictionary='/Default skin/translations'><r:form><r:select name='assigned' values=',1,2,3'/></r:form></r:load>"
tem: "/foo.*bar/"
res: "/value=\"1\">foo<\/option>\n<option value=\"2\">bar/"
2 changes: 1 addition & 1 deletion zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
s.date = %q{2012-01-30}
s.date = %q{2012-02-01}
s.default_executable = %q{zena}
s.description = %q{zena is a Ruby on Rails CMS (content managment system) with a focus on usability, ease of customization and web 2.0 goodness (application like behaviour).}
s.email = %q{gaspard@teti.ch}
Expand Down

0 comments on commit 77455e8

Please sign in to comment.