translate_str.patch
src/libaudqt/util.cc | ||
---|---|---|
70 | 70 |
if (! str) |
71 | 71 |
return nullptr; |
72 | 72 | |
73 |
const char * src = str; |
|
74 | ||
75 | 73 |
if (domain) |
76 |
src = dgettext (domain, src); |
|
77 | ||
78 |
StringBuf buf (strlen (src)); |
|
79 | ||
80 |
/* translate the gtk+ accelerator (_) into a qt accelerator (&), so we don't break the |
|
81 |
* translations. |
|
82 |
* |
|
83 |
* the translation rules are: if sentence begins with _ then translate, otherwise only |
|
84 |
* translate if the previous character is a space. the backtrack is safe as the first |
|
85 |
* condition will match if we're at the beginning. |
|
86 |
* |
|
87 |
* --kaniini |
|
74 |
str = dgettext (domain, str); |
|
75 | ||
76 |
/* translate the gtk+ accelerator (_) into a qt accelerator (&), |
|
77 |
* so we don't break the translations. |
|
88 | 78 |
*/ |
89 |
char * it = buf; |
|
90 |
const char * rit = src; |
|
91 | ||
92 |
for (; * rit; it++, rit++) |
|
93 |
{ |
|
94 |
if (*rit == '_') |
|
95 |
{ |
|
96 |
if (rit == src || *(rit - 1) == ' ') |
|
97 |
*it = '&'; |
|
98 |
else |
|
99 |
*it = *rit; |
|
100 |
} |
|
101 |
else |
|
102 |
*it = *rit; |
|
103 |
} |
|
79 |
StringBuf buf = str_copy (str); |
|
80 |
str_replace_char (buf, '_', '&'); |
|
104 | 81 | |
105 | 82 |
return buf; |
106 | 83 |
} |