Open SlySven opened 7 years ago
I guess this is nice to have in edbee... 😃 Improving I18n abilities
I was initially surprised how few of those strings count as User-visible and thus need translation for other languages but then as an editor widget I realised it was all about the users' text and really only help or warning messages would be seen from the widget itself...! 😮
One thing to be careful of where they are with tr(...)
or translate(...)
is to avoid building up sentences by appending fragments a bit at a time - that may not be workable where the order of those fragments actually need to change depending on the language - the Qt Documentation for their translation systems actually gives some examples of this Using Numbered Arguments - the example I recall compares the order of a couple of replacement variables (e.g. %1
and %2
) and showing how they have to be the opposite order in Norwegian compared to English!
Thanks for your comment. I double checked the TextEditorController::updateStatusText. (This is probably the only place with real I18n in edbee.).
It seems like QObject::tr is used correctly. It's true that the complete statusbar is build in fragments. But every fragment is a self-dependent piece with %1
and %2
.
If you think something needs to be changed, please feel free tell me..
Probably I'll get back to you when I have got Mudlet changing languages on the fly - and then it'll be seeking .ts
files with completed translations that we can merge into our project... 😈
\
Following on from #54 may I ask if it is possible to go through the whole
edbee-lib
library and convert all the uses ofQString("some string possibly with %1 or more variable argument replacement").arg(1)
to use either the:QStringLiteral(...)
form if the string is used internally and not user visibletr(...)
form if it will be user visible and require translation for use in non English(American) localesWhere a non-user visible constant
QString
is used as an argument to a function/method where aQLatin1String
is a valid argument type the alternativeQLatin1String(...)
is also viable but it does not support the%1
-%9
type variable (positional) replacement arguments thatQStringLiteral(...)
does.Ideally for the second type above if the string is a form where plurals are significant e.g. "You have just deleted X paragraph(s)." it would be best if the
%n
form is used, i.e.:I am requesting this because I am working on several aspects of I18n for the Mudlet project and in the near future I wish to add (run-time) GUI language selection (i.e. the user interface will be changeable to use another language) and part of that will use the Qt system for doing that which uses
QObject::tr()
;QCoreApplication::translate()
orQApplication::translate()
in C++ code to provide previously created translated versions of the (presumably "EN-us" or English{American}) source code strings. Obviously it would be beneficial if the editor can also support such a language change {ideally it will respond to receipt ofQEvent::LanguageChange
events to recreate any affected persistent texts - by regenerated them by reusingtr(...)
but for strings that are frequently changed anyway e.g. status-lines it probably will not need that level of coding and things will work well enough just by usingtr(...)
each time such a string is modified}._\_