Commit 089cccb050d76864c6efdbe6c0ba8daa037d5cca
1 parent
756e91de
Exists in
master
and in
28 other branches
ActionItem137: final adjustements in language_chooser
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1301 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
57 additions
and
21 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -157,8 +157,7 @@ module ApplicationHelper |
| 157 | 157 | def footer |
| 158 | 158 | # FIXME: add some information from the environment |
| 159 | 159 | [ |
| 160 | - content_tag('div', 'Copyright © 2007, Noosfero - Change Me!'), | |
| 161 | - content_tag('div', _('%s, version %s' % [ link_to('developers', 'http://www.colivre.coop.br/Noosfero'), Noosfero::VERSION])), | |
| 160 | + content_tag('div', _('This is %s, version %s' % [ link_to(Noosfero::PROJECT, 'http://www.colivre.coop.br/Noosfero'), Noosfero::VERSION])), | |
| 162 | 161 | ].join("\n") |
| 163 | 162 | end |
| 164 | 163 | ... | ... |
app/helpers/language_helper.rb
| 1 | 1 | module LanguageHelper |
| 2 | 2 | def language |
| 3 | - code = GetText.locale.to_s.downcase | |
| 4 | - (code == 'en_us') ? 'en' : code | |
| 3 | + code = GetText.locale.to_s | |
| 5 | 4 | end |
| 5 | + | |
| 6 | + def tinymce_language | |
| 7 | + language.downcase | |
| 8 | + end | |
| 9 | + | |
| 10 | + def language_chooser | |
| 11 | + current = language | |
| 12 | + Noosfero.locales.map do |code,name| | |
| 13 | + if code == current | |
| 14 | + content_tag('strong', name) | |
| 15 | + else | |
| 16 | + link_to(name, :lang => code) | |
| 17 | + end | |
| 18 | + end.join(' — ') | |
| 19 | + end | |
| 20 | + | |
| 6 | 21 | end | ... | ... |
app/views/shared/language_chooser.rhtml
| 1 | -<% Noosfero.locales.each do |locale_code,locale_name| %> | |
| 2 | - <% if GetText.locale.to_s == locale_code %> | |
| 3 | - <strong><%= locale_name %></strong> | |
| 4 | - <% else %> | |
| 5 | - <%= link_to locale_name, { :lang => locale_code }%> | |
| 6 | - <% end %> | |
| 7 | -<% end %> | |
| 1 | +<%= language_chooser %> | |
| 2 | + | |
| 3 | +<%= help(_('The language you choose here if the language used for options, buttons, etc. It does not affect the language of the content created by other users.'), _('Help on languages')) %> | ... | ... |
app/views/shared/tiny_mce.rhtml
| ... | ... | @@ -10,6 +10,6 @@ tinyMCE.init({ |
| 10 | 10 | theme_advanced_buttons2 : "bold,italic,underline,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,image,table,separator,cleanup,code", |
| 11 | 11 | theme_advanced_buttons3 : "", |
| 12 | 12 | apply_source_formatting : true, |
| 13 | - language: <%= language.inspect %>, | |
| 13 | + language: <%= tinymce_language.inspect %>, | |
| 14 | 14 | }); |
| 15 | 15 | </script> | ... | ... |
test/unit/language_helper_test.rb
| ... | ... | @@ -4,20 +4,46 @@ class LanguageHelperTest < Test::Unit::TestCase |
| 4 | 4 | |
| 5 | 5 | include LanguageHelper |
| 6 | 6 | |
| 7 | - def test_english | |
| 7 | + should 'return current language' do | |
| 8 | 8 | locale = mock |
| 9 | - locale.expects(:to_s).returns('en_us') | |
| 9 | + locale.expects(:to_s).returns('pt_BR') | |
| 10 | 10 | GetText.stubs(:locale).returns(locale) |
| 11 | - | |
| 12 | - assert_equal 'en', self.language | |
| 11 | + | |
| 12 | + assert_equal 'pt_BR', self.language | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | - def test_other_languages | |
| 16 | - locale = mock | |
| 17 | - locale.expects(:to_s).returns('pt_BR') | |
| 18 | - GetText.stubs(:locale).returns(locale) | |
| 15 | + should 'downcase language for tinymce' do | |
| 16 | + self.expects(:language).returns('pt_BR') | |
| 17 | + assert_equal 'pt_br', tinymce_language | |
| 18 | + end | |
| 19 | + | |
| 20 | + should 'generate language chooser correcly' do | |
| 21 | + Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once | |
| 22 | + | |
| 23 | + self.expects(:language).returns('pt_BR') | |
| 24 | + result = self.language_chooser | |
| 25 | + assert_match /<strong>Português Brasileiro<\/strong>/, result | |
| 26 | + assert_no_match /<strong>English<\/strong>/, result | |
| 27 | + assert_no_match /<strong>Français<\/strong>/, result | |
| 28 | + assert_no_match /<strong>Italiano<\/strong>/, result | |
| 29 | + | |
| 30 | + self.expects(:language).returns('fr') | |
| 31 | + result = self.language_chooser | |
| 32 | + assert_no_match /<strong>Português Brasileiro<\/strong>/, result | |
| 33 | + assert_no_match /<strong>English<\/strong>/, result | |
| 34 | + assert_match /<strong>Français<\/strong>/, result | |
| 35 | + assert_no_match /<strong>Italiano<\/strong>/, result | |
| 36 | + | |
| 37 | + end | |
| 38 | + | |
| 39 | + protected | |
| 40 | + | |
| 41 | + def content_tag(tag, text) | |
| 42 | + "<#{tag}>#{text}</#{tag}>" | |
| 43 | + end | |
| 19 | 44 | |
| 20 | - assert_equal 'pt_br', self.language | |
| 45 | + def link_to(text, opts) | |
| 46 | + "<a href='?lang=#{opts[:lang]}'>#{text}</a>" | |
| 21 | 47 | end |
| 22 | 48 | |
| 23 | 49 | end | ... | ... |