diff options
author | Miłosz Kosobucki <milosz@kosobucki.pl> | 2020-04-19 20:01:40 +0200 |
---|---|---|
committer | Miłosz Kosobucki <milosz@kosobucki.pl> | 2020-04-21 16:08:16 +0200 |
commit | d79e364d111463255e84c380ab7d91d3cf047456 (patch) | |
tree | 54597a9064aa799cac6e5e847073e95009cc57ae /doc/src/snippets | |
parent | 5cec5e99f391918c189d501e94523c3f1b5d3c73 (diff) |
Make docs encourage readers to query locale right
Currently the example shows the usage of "filename" + QLocale::name()
which will not work correctly for users with different locale and
display language. Even the QTranslator::load() docs discourage using
it in this way.
This approach is copied by users of Qt. For example in KDE:
https://github.com/search?q=org%3AKDE+%22%2B+QLocale%3A%3Asystem%28%29.name%28%29%22&type=Code
We should follow the best practice in the first place the user is going
to look at when working with i18n in Qt. Hopefully, with this change
the incorrect code will slowly die out.
Change-Id: I881f50f39740632bbd4640495270aae22bd44d0d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'doc/src/snippets')
-rw-r--r-- | doc/src/snippets/code/doc_src_i18n.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/src/snippets/code/doc_src_i18n.cpp b/doc/src/snippets/code/doc_src_i18n.cpp index 18a5def16..2bd80d5ab 100644 --- a/doc/src/snippets/code/doc_src_i18n.cpp +++ b/doc/src/snippets/code/doc_src_i18n.cpp @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); QTranslator myappTranslator; - myappTranslator.load("myapp_" + QLocale::system().name()); + myappTranslator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/i18n")); app.installTranslator(&myappTranslator); return app.exec(); |