Ticket #403 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

gobby some GUI strings are not localized in HEAD.

Reported by: takao.fujiwara@… Owned by: armin
Priority: normal Milestone: Gobby 0.4.8
Component: Gobby Version: 0.4.7
Severity: normal Keywords:
Cc: Launchpad Bug:

Description

Case1:
1. Invoke gobby on UTF-8 locales
2. Choose [Gobby] -> [Create Session] and click [Host]

Then "Opening obby session..." is not localized.
Then status bar of the main window has unlocalized "Line: %0%, Column: %1%".

3. Choose [Session] -> [Create Document]
4. Choose [Session] -> [Save Document]

Then "Auto Detect" is not localized.

5. Choose [Gobby] -> [Save Session]

Then "All files" is not localied.

Case2:
1. Invoke gobby on none UTF-8 locales.
2. Choose [Gobby] -> [Create Session] and click [Host]

Then chat window cannot show anything.

Case3:
1. Invoke gobby on none UTF-8 locales.
2. Choose [Gobby] -> [Create Session] and click [Host]
3. Choose [Session] -> [Create Document]
4. Choose [Session] -> [Save Document]

Then none UTF-8 file names cannot be saved.

I'm attaching the patch.

Attachments

gobby-xx-g11n-i18n-ui-head.diff (4.1 kB) - added by takao.fujiwara@… 4 years ago.
Patch for Case #1(src/encoding_selector.cpp, src/hostdialog.cpp, src/hostprogressdialog.cpp, src/statusbar.cpp, src/window.cpp)
gobby-xx-g11n-filename-head.diff (1.0 kB) - added by takao.fujiwara@… 4 years ago.
Patch for Case #2 and #3(src/logview.cpp, src/window.cpp)
gobby-xx-g11n-filename-head.2.diff (0.8 kB) - added by takao.fujiwara@… 4 years ago.
Revised the patch for none UTF-8

Change History

Changed 4 years ago by takao.fujiwara@…

Patch for Case #1(src/encoding_selector.cpp, src/hostdialog.cpp, src/hostprogressdialog.cpp, src/statusbar.cpp, src/window.cpp)

Changed 4 years ago by takao.fujiwara@…

Patch for Case #2 and #3(src/logview.cpp, src/window.cpp)

Changed 4 years ago by armin

Thanks for the patches.

I applied the first patch with a minor modification: I made EncodingSelection::get_encoding() and EncodingSelection::set_encoding() use the untranslated AUTO_DETECT string, so that other code can continue to compare it directly without worrying that it might be localized.

In the second patch, I don't quite understand this:

 	std::strftime(buf, 0x7f, formatter, &given_time_tm);
 	obby::format_string str("[%0%] %1%");
-	str << buf << ins_text.raw();
+	str << buf << Glib::locale_from_utf8(ins_text.raw());

Is the problem here that the result of strftime is in the current locale rather than UTF-8? If so, wouldn't it be better to convert it to UTF-8 instead of returning the other part of the string to the current locale (which might throw an exception, by the way, if the conversion fails)? A few lines below it needs to be in UTF-8 anyway to be displayed in the GtkTextView?.

Changed 4 years ago by takao.fujiwara@…

Is the problem here that the result of strftime is in the current locale rather than UTF-8?

Yes, the result of strftime is not ASCII but the current encoding.

wouldn't it be better to convert it to UTF-8

I guess you mean Glib::locale_to_utf8(buf) instead of Glib::locale_from_utf8(ins_text.raw()).
However Glib::locale_to_utf8(buf) doesn't work with str.

e.g.

obby::format_string str("[%0%] %1%");
str << Glib::locale_to_utf8(buf);
str.str() returns the current encoding instead of UTF-8.

I have no idea of obby::format.
Thanks.

Changed 4 years ago by armin

Could you try this with

str << Glib::locale_to_utf8(buf).raw()

instead, to prevent implicit charset conversion of Glib::ustring?

Changed 4 years ago by takao.fujiwara@…

str << Glib::locale_to_utf8(buf).raw()

In my env, it causes a SEGV in str.str().

Changed 4 years ago by armin

But you still added both buf and ins_text into the format_string, right? The whole line needs to like this:

str << Glib::locale_to_utf8(buf).raw() << ins_text.raw();

Otherwise, it crashes for me as well. Sorry if I wasn't clear enough.

Changed 4 years ago by takao.fujiwara@…

Revised the patch for none UTF-8

Changed 4 years ago by takao.fujiwara@…

Thanks for your explanation.
You're right totally. I didn't understand obby::format_string.
Now I revised the patch.

Could you also commit gobby-xx-ja-po.diff ?
http://gobby.0x539.de/trac/attachment/ticket/397/gobby-xx-ja-po.diff

Changed 4 years ago by armin

  • status changed from new to closed
  • resolution set to fixed

Thanks for the patch. Committed to master.

Note: See TracTickets for help on using tickets.