On 05/12/2016 08:49 AM, Ladislav Slezak wrote:
> Dne 12.5.2016 v 08:49 Lukas Ocilka napsal(a):
>> # Example
>>
>> ----------------------------------------------------------------------
>> You are trying to create subvolume {new_subvolume_name} which would be
>> shadowed by subvolume {old_subvolume_name} and thus might not produce
>> the desired effect. Continue despite the fact that we have warned you?
>> ----------------------------------------------------------------------
>>
>> In bad the example above, subvolumes can be short, but they can be also
>> very long. Some languages will use very long translation, some other
>> ones a shorter one.
> 
> My workaround is to put the variable text on a separate line to avoid text
> overflow, e.g [1]:
> 
>   # %s is an extension name, e.g. "SUSE Linux Enterprise Software Development 
> Kit"
>   Yast::Report.Error(_("Downloading the license for\n%s\nfailed.") % 
> addon.label)
> 

In this case i used same workaround, but i didn't take care of the first
line size and also we have the problems about unkown number of
interfaces per physical port id.

The code is something like that:
+      Popup.YesNoHeadline(
+        Label.WarningMsg,
+        _("The interfaces selected for bonding map to same physical
port \n" \
+          "and bonding them may not have the desire result.\n\n%s\n" \
+          "Really continue?\n") % message
+      )

And the message was something like:

+      message = ""
+
+      physical_port_ids.each do |port, devs|
+        message << "PhysicalPortID (#{port}): devs.join(', ')\n"
+      end

So after the Lukas suggestion i added:

+      message = ""
+
+      physical_port_ids.each do |port, devs|
+        message << "PhysicalPortID (#{port}):\n"
+        message << "#{devices_to_s(devs)}\n"
+      end

+    def devices_to_s(devices, wrap=78)
+      lines = []
+      message_line = ""
+      devices.map do |d|
+        if !message_line.empty? && "#{message_line}#{d}".size > wrap
+          lines << message_line
+          message_line = ""
+        end
+
+        message_line << ", " if !message_line.empty?
+        message_line << d
+      end
+      lines << message_line if !message_line.empty?
+
+      lines.join("\n")
+    end

The devices_to_s is almost the same method as the one referenced in
kobliha link.

And now i will try to take care of number of lines as you could have
many (physical_ports_ids).

You can see the results here:

https://trello-attachments.s3.amazonaws.com/56c43586c0fb23f985367990/735x552/342eb32f46f0630044ab53d90514a9aa/Screenshot_from_2016-05-12_12-30-25.png

Apart of the Rails wrap method, there is some gem
https://github.com/pazdera/word_wrap that implements it.




> This workaround makes sense when the text is usually long. When the variable
> text is short then it looks ugly.
> 
>> # Solution
>>
>> Basically something like `fold`, but implemented in Ruby without calling
>> shell. Maybe in Yast::String, maybe even as a Yast built-in (fold, wrap,
>> wrap_at).
> 
> Actually this should be implemented on the UI level as only the UI can know 
> how
> much space there is and how long text can fit there.
> 
> Moreover in Qt we use proportional font, that means "iiiiiiiiiiiiiiiiii"
> might fit while "mmmmmmmmmmmmmmmmmm" might not even though both have the
> exactly same number of characters. And I guess with non-Latin alphabets 
> (Arabic,
> Japanese, ...) it would break very easily...
> 
> The implementation at the YaST logic layer would not work well in many cases,
> IMHO that's a wrong place for this functionality.
> 
> 
> # Solution 2
> 
> My suggestion would be to add Opt(:wrap) option to the Label() widget which
> would enable the line wrapping. The text would be a single line and the UI
> would take care of breaking the lines at the appropriate places. Example:
> 
>   Label(Opt(:wrap), "verlongtext" * 42)
> 
> 
> What do you think about it?
> 
> 
> 
> [1]
> https://github.com/yast/yast-registration/blob/master/src/lib/registration/ui/addon_eula_dialog.rb#L87
> 
> --
> 
> Ladislav Slezák
> Appliance department / YaST Developer
> Lihovarská 1060/12
> 190 00 Prague 9 / Czech Republic
> tel: +420 284 028 960
> [email protected]
> SUSE
> 

-- 
Knut Alejandro Anderssen González
YaST Team at SUSE Linux GmbH
-- 
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to