How to get current application language
-
Thank you Dheerendra, but I don't think that helps.
I'm using QTranslator::load() and QCoreApplication::installTranslator() to translate the menus. But later I'd like to get the loaded language, out of the function that has the locale object.I already have a workaround for this, but I was just wondering if there is a direct way to get this information.
-
Thank you Dheerendra, but I don't think that helps.
I'm using QTranslator::load() and QCoreApplication::installTranslator() to translate the menus. But later I'd like to get the loaded language, out of the function that has the locale object.I already have a workaround for this, but I was just wondering if there is a direct way to get this information.
-
[quote author="koplersky" date="1421693019"]Thank you Dheerendra, but I don't think that helps.
I'm using QTranslator::load() and QCoreApplication::installTranslator() to translate the menus. But later I'd like to get the loaded language, out of the function that has the locale object.I already have a workaround for this, but I was just wondering if there is a direct way to get this information.[/quote]
What workaround did you use?
-
[quote author="koplersky" date="1421693019"]Thank you Dheerendra, but I don't think that helps.
I'm using QTranslator::load() and QCoreApplication::installTranslator() to translate the menus. But later I'd like to get the loaded language, out of the function that has the locale object.I already have a workaround for this, but I was just wondering if there is a direct way to get this information.[/quote]
What workaround did you use?
-
a little trick would be to add a translation for e.g. APP_LANGUAGE to every translation file and to translate it to the language's native name for each.
Then you simply can use
@
QObject::tr("APP_LANGUAGE")
@ -
a little trick would be to add a translation for e.g. APP_LANGUAGE to every translation file and to translate it to the language's native name for each.
Then you simply can use
@
QObject::tr("APP_LANGUAGE")
@ -
It turns out to be very simple:
http://stackoverflow.com/questions/28161888/how-to-find-current-qlocale-in-qt-pyqt-pysideJust enter
x=QtCore.QLocale()and then all the QLocale methods apply to x. E.g.,
x.language()That's Python, probably similar in c++
-
It turns out to be very simple:
http://stackoverflow.com/questions/28161888/how-to-find-current-qlocale-in-qt-pyqt-pysideJust enter
x=QtCore.QLocale()and then all the QLocale methods apply to x. E.g.,
x.language()That's Python, probably similar in c++
-
The current locale is not the same as the current application language. We allow switching the application language manually for instance (though the default is based on the locale).
-
The current locale is not the same as the current application language. We allow switching the application language manually for instance (though the default is based on the locale).
-
How about managing it logically?
Example: Maintain a member variable called m_currentLanguage to contain the information about current language and refer it whenever required.
-
How about managing it logically?
Example: Maintain a member variable called m_currentLanguage to contain the information about current language and refer it whenever required.