Commit graph

7 commits

Author SHA1 Message Date
Dirk Hohndel
7eaa2c62c4 Explicitly include needed include file
The Q_DECLARE_TR_FUNCTIONS macro is defined in QCoreApplication, so let's
make sure that's included.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:35:34 -07:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Maximilian Güntner
17fbb6b17f Support translating UTF8 strings
Interpreting UTF8 encoded strings using tr() instead of trUtf8()
and encoding the string back to utf8 again leads to serious encoding
errors.

Fixes #230

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:13:15 +09:00
Maximilian Güntner
2ef80930ff change the key from const char * to QByteArray
if trGettext() gets called with a *text that resides
in the stack, the QHash will return incorrect values after
the second call of trGettext() with that *text.

Example (assuming nothing has been translated):

void func(const char *text) {
        char *translated = trGettext(text);
        doSomethingWith(translated);
}

func("foo"); (1)
func("bar"); (2)

(1) *translated is "foo"
(2) *translated should be "bar" but is "foo" because
    the key (const char*) points to the value "foo"
    which has been set in the previous call (1).

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-11-02 02:55:02 +01:00
Dirk Hohndel
86a80d37eb Dismbiguate gettext
Just to make sure there's no confusion - we are NOT calling gettext. We
are calling tr from a gettext like interface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10 00:18:26 -07:00
Dirk Hohndel
2e43769108 Avoid the memory leaks from translations
Instead use a hash to cache the translations (and allow for the ability to
clear the hash so we can even switch translations at runtime...).

Now Qt will keep track of the memory and release it for us when we are
done with it.

This avoids the memory leak introduced in commit 4ecb35bf5ff2 ("Make a
copy of the translated text").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08 23:11:28 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00