String that is able to hold international (UTF-8) strings for the user interface.
More...
|
| uiString () |
|
| uiString (const char *)=delete |
|
| uiString (const char *original, const char *context, const char *package, const char *disambiguation, int pluralnr) |
|
| uiString (const uiString &) |
| no copy, ref counted More...
|
|
| ~uiString () |
|
void | addAlternateVersion (const uiString &) |
|
void | addLegacyVersion (const uiString &uistr) |
|
uiString & | addMoreInfo (const char *) |
|
template<class T > |
uiString & | addMoreInfo (const T &) |
|
uiString & | addMoreInfo (const uiString &, bool newline=false) |
| will deliver ": the string with more info" More...
|
|
uiString & | addNewLine (int=1) |
|
uiString & | addSpace (int=1) |
|
uiString & | addTab (int=1) |
|
uiString & | append (const char *s, bool nl=false) |
|
uiString & | append (const OD::String &s, bool nl=false) |
|
uiString & | append (const uiString &s, bool nl=false) |
|
uiString & | appendAfterList (const uiString &) |
|
uiString & | appendIncorrect (const char *, char sep=' ') |
|
uiString & | appendIncorrect (const OD::String &, char sep=' ') |
|
uiString & | appendIncorrect (const uiString &, char sep=' ') |
|
uiString & | appendPhrase (const uiString &, SeparType septyp=uiString::CloseLine, AppendType apptyp=uiString::OnNewLine) |
|
uiString & | appendPhrases (const uiStringSet &, SeparType septyp=uiString::CloseLine, AppendType apptyp=uiString::OnNewLine) |
|
uiString & | appendPhraseSameLine (const uiString &) |
|
uiString & | appendPlainText (const char *, bool addspace=false, bool addquotes=false) |
|
uiString & | appendPlainText (const OD::String &, bool addspace=false, bool addquotes=false) |
|
template<class T > |
uiString & | arg (const T &) |
|
uiString & | arg (const uiString &) |
|
uiString & | arg (double, int nrdecimals) |
|
uiString & | arg (float, int nrdecimals) |
|
uiString & | constructWordWith (const uiString &, bool addspace=false) |
|
wchar_t * | createWCharString () const |
| returns new string: use 'delete []'. More...
|
|
uiString & | embed (const char *open, const char *close) |
|
uiString & | embedFinalState () |
|
void | encodeStorageString (BufferString &) const |
|
const QString & | fillQString (QString &) const |
| translated with arguments inserted More...
|
|
void | fillUTF8String (BufferString &) const |
| translated with arguments inserted More...
|
|
const OD::String & | getFullString (BufferString *=nullptr) const |
|
void | getHexEncoded (BufferString &) const |
|
const char * | getOriginalString () const |
| untranslated, no argument substitution More...
|
|
const QString & | getQString () const |
|
BufferString | getString () const |
| untranslated but arguments evaluated More...
|
|
bool | isEmpty () const |
|
bool | isPlainAscii () const |
|
bool | isSet () const |
|
void | makeIndependent () |
| Reads hex-data and sets the translated str. More...
|
|
bool | operator! () const |
|
bool | operator!= (const uiString &oth) const |
|
bool | operator< (const uiString &b) const |
|
uiString & | operator= (const char *)=delete |
|
uiString & | operator= (const uiString &) |
| no copy, ref counted More...
|
|
bool | operator== (const uiString &oth) const |
|
bool | operator> (const uiString &b) const |
|
uiString & | optional () |
|
uiString & | parenthesize () |
|
uiString & | postFixWord (const uiString &) |
|
uiString & | preFixWord (const uiString &) |
|
uiString & | quote (bool single) |
|
uiString & | set (const char *) |
|
uiString & | set (const uiString &s) |
|
uiString & | setArg (int, const uiString &) |
|
void | setEmpty () |
|
void | setFrom (const QString &) |
|
bool | setFromHexEncoded (const char *) |
|
int | size () const |
|
uiString & | toLower (bool yn=true) |
| applied before arg subst. More...
|
|
uiString & | toTitleCase () |
|
uiString & | toUpper (bool yn=true) |
|
bool | translate (const QTranslator &, QString &) const |
| Returns true if the translation succeeded. More...
|
|
int | useEncodedStorageString (const char *) |
| returns -1 for fail, >= 0 the number of chars used More...
|
|
uiString & | withNumber (std::int64_t) |
|
uiString & | withSurvDepthUnit () |
|
uiString & | withSurvXYUnit () |
|
uiString & | withSurvZUnit () |
|
uiString & | withUnit (const char *) |
| just the unit itself, please More...
|
|
uiString & | withUnit (const uiString &) |
|
String that is able to hold international (UTF-8) strings for the user interface.
uiString is reference counted; Making a copied object is cheap.
The string will have an 'original string' of simple ASCI characters, which can be used as a 'key' but never for user display.
The string can have %1, %2, ... arguments. For these, sooner or later arguments must be provided, as in: uiString string = tr("%1 plus %2 is %3").arg( 4 ).arg( 5 ).arg( 4+5 ); ... will result in the string "4 plus 5 is 9"
As such, uiString's are suited for limited text manipulation. But if we are doing this for translated words and phrases, beware that alteration and combining is not right. Tranalations allow: Entire phrases to be concatenated Construction of lists with certain 'reasonable' separators. In no case, just glue together words and/or verbs into your own phrases.
The translation in OpendTect is done using Qt's subsystem for localization. A class that needs to use localized strings should:
- In many cases, you can pick your stuff from the uiStrings common words and phrases defined in uistrings.h.
- If you need specific words or phrases not in uistrings.h, then use the mTextTranslationClass(classname,packagekey) macro. The packagekey is a string that identifies your software package (probably a short plugin name). OpendTect's internal classes use the "od" package string, and can for short use the mODTextTranslationClass macro.
- Use the tr() function for all non-standard strings. The tr() function returns a uiString that can be passed to the ui.
- For functions not belonging to a class, use the od_static_tr function. Any function matching the *_static_tr will be interpreted by Qt's lupdate.
Notes:
Use the pre-translated strings and phrases in uistrings.h as often as possible. Examples: uiStrings::phrCannotRead() and uiStrings::sTraceNumber().
Do not juggle with words to construct phrases. This will lead to bad translations, sometimes hilarious stuff. You can however join multiple phrases into one error message. Prefer this style:
uiString msg( tr("Rendering %1 data in background").arg(objnm) ); msg.appendPhrase( tr("When finished, the image will appear") );
Note the absence of '.' at the end of lines - these phrase terminators should be added if necessary depending on the situation. Do not put them in tr() messages. There are options for different separators when appending.
All uiStrings:sXXX() start with a capital. To get the no-caps or all-caps versions, simply use toLower() and toUpper(), as in: uiStrings::sColumn().toLower()
Units of measure are not translated. Some common units may have a translation, if they are not abbreviated. For example, 'ft' is not translated, 'Feet' is. Easy to use is uiStrings::sFeet( bool abbreviation=true );
You can add 'delimiters' and 'embedding' to words ot phrases. Try to not juggle with these yourself, make sure things are handled in a decent, standard way. For example, there is a uiString::withUnit() that adds the unit (if not empty) with parentheses. Also look at parenthesize(), embed(), optional(), ...
m3Dots: This is only for menus. For buttons, the last argument 'immediate' determines the possible 3 dots at the end of the text. m3Dots is therefore for menu items only (which actually should have been designed to use the same construction, a design error). Set the flag to false and the user will expect a new dialog to pop up rather than immediate action. So the button object will add the '...' if that is the style (but that may change).
<>