| Summary: | SimpleWelcome translates KDE places (bookmarks) | ||
|---|---|---|---|
| Product: | [ROSA-based products] ROSA Fresh | Reporter: | Dmitry <dmitry.ashkadov> |
| Component: | Packages from Main | Assignee: | ROSA Linux Bugs <bugs> |
| Status: | RESOLVED FIXED | QA Contact: | ROSA Linux Bugs <bugs> |
| Severity: | normal | ||
| Priority: | Normal | CC: | alex.burmashev, andrey.bondrov, dmitry.postnikov, v.potapov |
| Version: | unspecified | Flags: | v.potapov:
qa_verified+
alex.burmashev: published+ |
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Platform: | --- | ROSA Vulnerability identifier: | |
| RPM Package: | ISO-related: | ||
| Bad POT generating: | Upstream: | ||
|
Description
Dmitry
2014-04-19 23:33:59 MSK
Close Dolphin, then start it again. You'll see "Музыка" instead of Music. That's how KDE works. You can either translate bookmarks or not. New build list: https://abf.rosalinux.ru/build_lists/1799569 https://abf.rosalinux.ru/build_lists/1799570 This build doesn't resolve the issue, just adds context where to look for translations: - newItem["caption"] = i18n(bm.fullText().toUtf8()); + newItem["caption"] = ki18nc("KFile System Bookmarks",bm.fullText().toUtf8()).toString(); I suggest to approve these builds ASAP. -1, I would prefer don't apply that patch because: 1) that is really bad code 2) an application should never translate string that is set by the user (In reply to comment #3) > -1, I would prefer don't apply that patch because: > 1) that is really bad code Surely it's a workaround, not a final solution. But is there anything better? > 2) an application should never translate string that is set by the user That requires re-work of kdelibs code. Currently there's no way to figure out what bookmarks were set (or just renamed) by user and what were set by default setup. New build lists: https://abf.rosalinux.ru/build_lists/1799843 https://abf.rosalinux.ru/build_lists/1799844 It's still not possible to rename default bookmarks to English names in KDE ("Музыка" -> "Music" etc). But now SW doesn't translate custom bookmarks. Is is NOT possible to rename default bookmarks (places). That is not a solution. (In reply to comment #4) > (In reply to comment #3) > > -1, I would prefer don't apply that patch because: > > 1) that is really bad code newItem["caption"] = i18nc("KFile System Bookmarks", bm.text().toUtf8().data()); -> QByteArray chars = bm.text().toUtf8(); newItem["caption"] = i18nc("KFile System Bookmarks", chars.data()); (In reply to comment #7) > (In reply to comment #4) > > (In reply to comment #3) > > > -1, I would prefer don't apply that patch because: > > > 1) that is really bad code > > newItem["caption"] = i18nc("KFile System Bookmarks", > bm.text().toUtf8().data()); > > -> > > QByteArray chars = bm.text().toUtf8(); > newItem["caption"] = i18nc("KFile System Bookmarks", chars.data()); Doesn't make any sense. It does matter. Your code is undefined behavior. (In reply to comment #9) > It does matter. Your code is undefined behavior. This code comes from kfileplacesitem.cpp (from void KFilePlacesItem::setBookmark(const KBookmark &bookmark) ) and has been tested for years. And there's nothing more undefined in char *data = bm.text().toUtf8().data(); than in QString text = bm.text(); QByteArray chars = text.toUtf8(); char *data = chars.data(); Tested over the years code does not mean that the code is right. Because many programmers make that mistake. char *data = bm.text().toUtf8().data(); do_some(data); You are dereferencing the wild pointer (it is undefined behavior), because bm.text().toUtf8() creates temporary and the compiler can destroy it when it is unused. "data" can become wild pointer. (In reply to comment #11) > Tested over the years code does not mean that the code is right. Because > many programmers make that mistake. > > char *data = bm.text().toUtf8().data(); > do_some(data); > > You are dereferencing the wild pointer (it is undefined behavior), because > bm.text().toUtf8() creates temporary and the compiler can destroy it when it > is unused. "data" can become wild pointer. Makes sense for a longer usage. But in i18nc("KFile System Bookmarks", bm.text().toUtf8().data()) we use the pointer right after creating it. And use only one. Even with -Wall and -Wextra there are no warnings about this line. Anyway, just commit whatever you think should be there. It's your software, not mine... But please note that we need to close this bug ASAP. > Makes sense for a longer usage. ??? The C++ standard disagrees with you. > But in i18nc("KFile System Bookmarks", bm.text().toUtf8().data()) we use the > pointer right after creating it. And use only one. The data pointed with pointer may be destroyed before i18nc() is executed. > > Even with -Wall and -Wextra there are no warnings about this line. A compiler can't understand that situation. > Anyway, just commit whatever you think should be there. It's your software, > not mine... But please note that we need to close this bug ASAP. Sorry, but it is your patch, not mine. Your patch works because GCC don't destroy temporary ASAP and an application should not translate strings from system. (In reply to comment #13) > and an application should not translate strings from system How do you expect these stings to be translated then? Of course it's easy to modify kbookmark.cc in this way: - return text; + return ki18nc("KFile System Bookmarks", text.toUtf8()).toString(); But this will break kfileplaces', Dolphin' etc logic. Do you know what code translates bookmarks? Мужики, выдайте уж какой-нибудь рабочий результат, хватит крутостью мерятся, надо r3 выпускать и чтоб при первом запуске все было переведено. Остальное вторично. Тише! У них тут "сражение на саблях". :) (In reply to comment #16) > Мужики, выдайте уж какой-нибудь рабочий результат, хватит крутостью мерятся, > надо r3 выпускать и чтоб при первом запуске все было переведено. > Остальное вторично. http://bugs.rosalinux.ru/show_bug.cgi?id=3985#c5 (In reply to comment #15) > Do you know what code translates bookmarks? Yes, various code in various places. It's quite a mess in KDE. For example, this one from kdelibs/kfile/kfileplacesitem.cpp ========================================= void KFilePlacesItem::setBookmark(const KBookmark &bookmark) { m_bookmark = bookmark; if (bookmark.metaDataItem("isSystemItem") == "true") { // This context must stay as it is - the translated system bookmark names // are created with 'KFile System Bookmarks' as their context, so this // ensures the right string is picked from the catalog. // (coles, 13th May 2009) m_text = i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data()); } else { m_text = bookmark.text(); } } http://quickgit.kde.org/?p=kdelibs.git&a=blob&h=1cb0fa58c82d520e51f1446b699bc1efd99c5a6d&hb=471f91e98c0c1f7cf7c8abcae3ae97cb025f146e&f=kfile%2Fkfileplacesitem.cpp ========================================= or this one from dolphin/src/panels/places/placesitemmodel.cpp ========================================= const KUrl url = bookmark.url(); if (missingSystemBookmarks.contains(url)) { missingSystemBookmarks.remove(url); // Try to retranslate the text of system bookmarks to have translated // items when changing the language. In case if the user has applied a custom // text, the retranslation will fail and the users custom text is still used. // It is important to use "KFile System Bookmarks" as context (see // createSystemBookmarks()). item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data())); item->setSystemItem(true); } http://quickgit.kde.org/?p=kde-baseapps.git&a=blob&h=baa770dfdb8d1b2fc79ec313c10fbb5bc38fbd79&hb=d22f3b16ab84710f3af8d49b8efded13d18a8af0&f=dolphin%2Fsrc%2Fpanels%2Fplaces%2Fplacesitemmodel.cpp ========================================= and so on. (In reply to comment #16) > Мужики, выдайте уж какой-нибудь рабочий результат, хватит крутостью мерятся, > надо r3 выпускать и чтоб при первом запуске все было переведено. > Остальное вторично. Выше есть хоть какой-то вариант. rosa-launcher-2.0.0-55.5 http://abf-downloads.rosalinux.ru/rosa2012.1/container/1799843/i586/main/release/ http://abf-downloads.rosalinux.ru/rosa2012.1/container/1799844/x86_64/main/release/ ************************** Advisory ************************** Fix bug with SimpleWelcome translates bookmarks named in English ************************************************************** QA Verified |