samizdat-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

separate-translations 070618-1 - still buggy


From: boud
Subject: separate-translations 070618-1 - still buggy
Date: Tue, 26 Jun 2007 02:15:26 +0200 (CEST)

hi samizdat-devel,

On Sun, 24 Jun 2007, boud wrote:
On Mon, 18 Jun 2007, Dmitry Borodaenko wrote:
Changes: translation is displayed in place of original in full mode
(when clicking to view the message) -- and the other way around,
original is listed and displayed in place of preferred translation,
all translations are dropped from replies list and are only available
through the list of translations in message info line, reply button is
not displayed on translation (no sense to enforce this latter rule
more strictly, as messages still can gain and loose status of
translation by changing the rating of their relation to Translation
focus).

Please give feedback, how does it compare to separate translation 0.2 patch?


It definitely is on the right track and looks good.

i still agree with this :) but it still needs some more work.

The 070618 version seems to work correctly only when the parent article
is in the accept_language. Otherwise, there is a problem.

The different cases to be checked for any proposed solution include:


* = in accept_language
the entries show what we want


database point of view: parent*   child         parent     child*

user point of view     parent    child         child      parent

Add another focus      parent    parent        parent     parent

Edit                   parent    child         child      parent
afterwards: Redirect   parent    child         child      parent

Hide, Unhide, Reparent, Takeover, Replace - mostly the same as Edit


Below is a patch which corrects for some of the cases - though it has
the side effect that "Add another focus" does not always apply to the parent (which is a nice effect of the 070618 version), and it does not provide a full solution - several cases are still wrong.


cheers
boud





--- /tmp/tmp_snapshot/samizdat/lib/samizdat/models/message.rb   2007-06-18 
21:26:49.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/models/message.rb        2007-06-26 
01:15:05.107734864 +0200
@@ -158,6 +158,14 @@
     @parent and @focuses.include?(Focus.translation_focus)
   end

+  def is_parent_lang_preferred?(accept_language)
+ if @parent + parent = Message.cached(@parent)
+      parent.lang == accept_language
+    end
+  end
+
+
   # find available translation to the most preferred language
   #
   # returns Message object or self, when no translation is suitable

--- /tmp/tmp_snapshot/samizdat/lib/samizdat/helpers/message_helper.rb   
2007-06-18 21:19:43.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/helpers/message_helper.rb        2007-06-26 
01:34:06.295247992 +0200
@@ -135,6 +135,14 @@
     buttons = ''

     if not message.version_of   # no buttons for old versions
+
+    # optimize: don't run select_translation 3 times here and in message()
+    # and in message_info
+#    translation = (message.lang == @request.accept_language) ?
+#       message : message.select_translation(@request.accept_language)
+      translation = 
(message.is_parent_lang_preferred?(@request.accept_language)) ?
+         message : message.select_translation(@request.accept_language)
+
       if @request.access('post')
         unless message.is_translation?
           # don't allow to post replies to translations
@@ -151,26 +159,27 @@
             message.open
           end
         if open
-          buttons << message_button(message.id, 'edit', _('Edit'))
+#          buttons << message_button(message.id, 'edit', _('Edit'))
+          buttons << message_button(translation.id, 'edit', _('Edit'))
         end
       end

       if @request.moderate?
         buttons <<
           message_button(
-            message.id,
+            translation.id,
             message.hidden? ? 'unhide' : 'hide',
             message.hidden? ? _('UNHIDE') :  _('HIDE'),
             :moderator_action
           ) <<
-          message_button(message.id, 'reparent', _('REPARENT'), :moderator_action) 
<<
-          message_button(message.id, 'takeover', _('TAKE OVER'), :moderator_action) 
<<
-          message_button(message.id, 'replace', _('REPLACE'), 
:moderator_action)
+          message_button(translation.id, 'reparent', _('REPARENT'), 
:moderator_action) <<
+          message_button(translation.id, 'takeover', _('TAKE OVER'), 
:moderator_action) <<
+          message_button(translation.id, 'replace', _('REPLACE'), 
:moderator_action)
       end

     elsif @request.moderate?   # old versions can still be replaced
       buttons <<
-        message_button(message.id, 'replace', _('REPLACE'), :moderator_action)
+        message_button(translation.id, 'replace', _('REPLACE'), 
:moderator_action)
     end

     ('' == buttons) ? '' : %{<div class="foot">#{buttons}</div>\n}
@@ -184,7 +193,7 @@
   #
   def message(message, mode)
     info = message_info(message, mode)
-
+
     translation = (:preview == mode) ?
       message :
       message.select_translation(@request.accept_language)
--- /tmp/tmp_snapshot/samizdat/lib/samizdat/controllers/message_controller.rb   
2007-06-18 13:01:02.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/controllers/message_controller.rb        
2007-06-26 01:43:28.902718656 +0200
@@ -171,7 +171,8 @@
         @old_content.move_upload(@request, @id, version_id)
         @message.content.move_upload(@request)
       end
-      @request.redirect(@message.id)
+#      @request.redirect(@message.id)
+      
@request.redirect(@message.select_translation(@request.accept_language).id)
     elsif @request.has_key? 'preview'
       preview
     else


######################################################################




reply via email to

[Prev in Thread] Current Thread [Next in Thread]