From 805d44a5b8f9783afb59ab74f581b9b0e44dba38 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 22 Oct 2015 00:40:24 +0100 Subject: [PATCH] [loc] fix additional right-to-left issues * Fix mishandling of spaces after period, comma, colon, etc. * Fix Test/Alpha notifications not displaying properly in RTL mode * Part of #621 --- res/localization/rufus.loc | 13 ++++++------- src/license.h | 4 ++-- src/localization.c | 10 ++++++++-- src/localization.h | 5 ++++- src/rufus.c | 10 +++++----- src/rufus.h | 1 + src/rufus.rc | 12 ++++++------ src/stdlg.c | 12 ++++++------ 8 files changed, 38 insertions(+), 29 deletions(-) diff --git a/res/localization/rufus.loc b/res/localization/rufus.loc index 331c2064..d90782ab 100644 --- a/res/localization/rufus.loc +++ b/res/localization/rufus.loc @@ -840,12 +840,11 @@ t MSG_171 "بدء عملية الفرمتة. \nستم تدمير أية بيان t MSG_172 "معلومات الترخيص و اعتراف بالفضل" t MSG_173 "إضغط لاختيار..." # The following will appear in the about dialog -# NOTE: In the line below, there are (potentially) invisible Right-To-Left marks -# (UTF-8: 0xE2 0x80 0x8f) After "USB" and after "Rufus". -t MSG_174 "Rufus‏ - أداة فرمتة الـ USB‏ جديرة بالثقة" -# This one's a massive empirical fest of RTL marks and nonsensical parenthesis, to -# make the output look about right... If you edit this, all I can say is: GOOD LUCK!!! -t MSG_175 "إصدار ‏ %d.%d‏)بناء‏ ‏%d‏(" +# NOTE: Because it starts with English text, the line below requires an invisible +# RIGHT-TO-LEFT EMBEDDING (UTF-8: 0xE2 0x80 0xAB) at the beginning and a +# POP DIRECTIONAL FORMATTING (UTF-8: 0xE2 0x80 0xAC) at the end. +t MSG_174 "‫Rufus - أداة فرمتة الـ USB جديرة بالثقة‬" +t MSG_175 "إصدار %d.%d (بناء %d)" t MSG_176 "الترجمة العربية: عمر الصمد، تحديث: جلال شفرور (mailto:ch_djalel@yahoo.com)" t MSG_177 "إخبار عن مشكلة أو طلب تعديلات على:" t MSG_178 "حقوق الطبع والنشر الإضافية:" @@ -856,7 +855,7 @@ t MSG_181 "نظامك التشغيلي والإصدار" t MSG_182 "إصدار البرنامج الذي تستخدمه" t MSG_183 "عنوان الـIP الخاص بك" t MSG_184 "لغرض إنشاء إحصاءات الإستخدام الخاص, قد نقوم بالحفاظ علي المعلومات التي تم جمعها, " - "\\b لسنة واحدة كحدّ أقصى \\b0 . لكننا لن نقوم بالكشف عن أي من هذه البيانات الفردية إلى أطراف ثالثة." + "\\b لسنة واحدة كحدّ أقصى\\b0 . لكننا لن نقوم بالكشف عن أي من هذه البيانات الفردية إلى أطراف ثالثة." t MSG_185 "إجراء التحديث:" t MSG_186 "روفوس لا يقوم بتثبيت أو تشغيل خدمات خلفية, وبالتالي يتم التحقّق من تحديثات فقط عند تشغيل التطبيق الرئيسي. \\line\n" "الإتصال بالإنترنت بالطبع مطلوب عند التحقّق من وجود تحديثات." diff --git a/src/license.h b/src/license.h index 2078f167..9b3d2225 100644 --- a/src/license.h +++ b/src/license.h @@ -19,7 +19,7 @@ const char* about_blurb_format = "{\\rtf1\\ansi\n" -"{\\b\\fs20%s}\\line\n" +"\\b\\fs20%s\\b0\\line\n" "\\fs18%s\\line\n" "\\line\n" "%s\\line\n" @@ -30,7 +30,7 @@ RUFUS_URL "\\line\n" "%s\\line\n" "https://github.com/pbatard/rufus/issues\\line\n" "\\line\n" -"{\\b\\fs19 %s}}"; +"\\b\\fs19 %s\\b0}"; const char* additional_copyrights = "{\\rtf1\\ansi\n" diff --git a/src/localization.c b/src/localization.c index 95ed6c11..eb8d6fc4 100644 --- a/src/localization.c +++ b/src/localization.c @@ -375,7 +375,7 @@ void reset_localization(int dlg_id) * Uses a rolling list of buffers to allow concurrency * TODO: use dynamic realloc'd buffer in case LOC_MESSAGE_SIZE is not enough */ -char* lmprintf(int msg_id, ...) +char* lmprintf(uint32_t msg_id, ...) { static int buf_id = 0; static char buf[LOC_MESSAGE_NB][LOC_MESSAGE_SIZE]; @@ -383,7 +383,9 @@ char* lmprintf(int msg_id, ...) va_list args; buf_id %= LOC_MESSAGE_NB; buf[buf_id][0] = 0; + BOOL needs_rtf_rtl_marks = (msg_id & MSG_RTF) && right_to_left_mode; + msg_id &= MSG_MASK; if ((msg_id > MSG_000) && (msg_id < MSG_MAX)) { format = msg_table[msg_id - MSG_000]; } @@ -391,9 +393,13 @@ char* lmprintf(int msg_id, ...) if (format == NULL) { safe_sprintf(buf[buf_id], LOC_MESSAGE_SIZE-1, "MSG_%03d UNTRANSLATED", msg_id - MSG_000); } else { + if (needs_rtf_rtl_marks) + safe_strcpy(buf[buf_id], LOC_MESSAGE_SIZE-1, "\\rtlch"); va_start(args, msg_id); - safe_vsnprintf(buf[buf_id], LOC_MESSAGE_SIZE-1, format, args); + safe_vsnprintf(&buf[buf_id][needs_rtf_rtl_marks?6:0], LOC_MESSAGE_SIZE-1, format, args); va_end(args); + if (needs_rtf_rtl_marks) + safe_strcat(buf[buf_id], LOC_MESSAGE_SIZE-1, "\\ltrch"); buf[buf_id][LOC_MESSAGE_SIZE-1] = '\0'; } return buf[buf_id++]; diff --git a/src/localization.h b/src/localization.h index e63bd80f..c4b1ab9e 100644 --- a/src/localization.h +++ b/src/localization.h @@ -37,6 +37,9 @@ // the translation will be ignored #define LOC_FRAMEWORK_VERSION 1 +#define MSG_RTF 0x10000000 +#define MSG_MASK 0x0FFFFFFF + #define luprint(msg) uprintf("%s(%d): " msg "\n", loc_filename, loc_line_nr) #define luprintf(msg, ...) uprintf("%s(%d): " msg "\n", loc_filename, loc_line_nr, __VA_ARGS__) @@ -166,7 +169,7 @@ void _exit_localization(BOOL reinit); void apply_localization(int dlg_id, HWND hDlg); void reset_localization(int dlg_id); void free_dialog_list(void); -char* lmprintf(int msg_id, ...); +char* lmprintf(uint32_t msg_id, ...); BOOL get_supported_locales(const char* filename); BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd); void free_locale_list(void); diff --git a/src/rufus.c b/src/rufus.c index 92db7d83..118c7c14 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -1577,7 +1577,7 @@ static __inline const char* IsAlphaOrBeta(void) #elif defined(BETA) return " (Beta) "; #elif defined(TEST) -# define TEST_STR(x) " (Test" STRINGIFY(x) ")" +# define TEST_STR(x) " (Test" STRINGIFY(x) ") " return TEST_STR(TEST); #else return " "; @@ -2151,12 +2151,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA #if defined(ALPHA) // Add a VERY ANNOYING popup for Alpha releases, so that people don't start redistributing them - Notification(MSG_INFO, NULL, "ALPHA VERSION", "This is an Alpha version of " APPLICATION_NAME - " - It is meant to be used for testing ONLY and should NOT be distributed as a release."); + MessageBoxA(NULL, "This is an Alpha version of " APPLICATION_NAME " - It is meant to be used for " + "testing ONLY and should NOT be distributed as a release.", "ALPHA VERSION", MSG_INFO); #elif defined(TEST) // Same thing for Test releases - Notification(MSG_INFO, NULL, "TEST VERSION", "This is a Test version of " APPLICATION_NAME - " - It is meant to be used for testing ONLY and should NOT be distributed as a release."); + MessageBoxA(NULL, "This is a Test version of " APPLICATION_NAME " - It is meant to be used for " + "testing ONLY and should NOT be distributed as a release.", "TEST VERSION", MSG_INFO); #endif return (INT_PTR)FALSE; diff --git a/src/rufus.h b/src/rufus.h index 9f248c84..a518a776 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -47,6 +47,7 @@ #define LEFT_TO_RIGHT_EMBEDDING "‪" #define RIGHT_TO_LEFT_EMBEDDING "‫" #define POP_DIRECTIONAL_FORMATTING "‬" +#define RIGHT_TO_LEFT_OVERRIDE "‮" #define DRIVE_ACCESS_TIMEOUT 15000 // How long we should retry drive access (in ms) #define DRIVE_ACCESS_RETRIES 60 // How many times we should retry #define DRIVE_INDEX_MIN 0x00000080 diff --git a/src/rufus.rc b/src/rufus.rc index 2760d0d6..7b840be0 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 2.5.785" +CAPTION "Rufus 2.5.786" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -156,7 +156,7 @@ FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20 DEFPUSHBUTTON "Close",IDCANCEL,221,172,50,14,WS_GROUP - CONTROL "",IDC_POLICY,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x804,46,8,235,132,WS_EX_STATICEDGE + CONTROL "",IDC_POLICY,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_TABSTOP,46,8,235,132,WS_EX_STATICEDGE GROUPBOX "Settings",IDS_UPDATE_SETTINGS_GRP,45,145,165,46 LTEXT "Check for updates",IDS_UPDATE_FREQUENCY_TXT,51,159,76,11 COMBOBOX IDC_UPDATE_FREQUENCY,133,155,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -319,8 +319,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,5,785,0 - PRODUCTVERSION 2,5,785,0 + FILEVERSION 2,5,786,0 + PRODUCTVERSION 2,5,786,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -337,13 +337,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.5.785" + VALUE "FileVersion", "2.5.786" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", " 2011-2015 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.5.785" + VALUE "ProductVersion", "2.5.786" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 7d95df14..b6534f63 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -609,10 +609,10 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP CenterDialog(hDlg); if (settings_commcheck) ShowWindow(GetDlgItem(hDlg, IDC_ABOUT_UPDATES), SW_SHOW); - safe_sprintf(about_blurb, sizeof(about_blurb), about_blurb_format, lmprintf(MSG_174), - lmprintf(MSG_175, rufus_version[0], rufus_version[1], rufus_version[2]), + safe_sprintf(about_blurb, sizeof(about_blurb), about_blurb_format, lmprintf(MSG_174|MSG_RTF), + lmprintf(MSG_175|MSG_RTF, rufus_version[0], rufus_version[1], rufus_version[2]), right_to_left_mode?"Akeo \\\\ Pete Batard 2011-2015 © Copyright":"Copyright © 2011-2015 Pete Batard / Akeo", - lmprintf(MSG_176), lmprintf(MSG_177), lmprintf(MSG_178)); + lmprintf(MSG_176|MSG_RTF), lmprintf(MSG_177|MSG_RTF), lmprintf(MSG_178|MSG_RTF)); for (i=0; i