Fix translation of migration-notification dialog.
Was being shown before locale was selected, so always using default translation. Fixed by deferring the dialog, and also added an assert for debug builds, if trying to access translated string too early.
This commit is contained in:
parent
42ed210c9c
commit
00d34b67e1
4 changed files with 29 additions and 14 deletions
|
@ -787,15 +787,9 @@ static void tryAutosaveMigration(const SGPath& userDataPath, SGPropertyNode* pro
|
|||
// copy remaining props out
|
||||
copyProperties(&oldProps, props);
|
||||
|
||||
// inform the user
|
||||
FGLocale *locale = globals->get_locale();
|
||||
const auto title = locale->getLocalizedString("settings-migration-title", "sys", "Settings migrated");
|
||||
const auto msg = locale->getLocalizedString("settings-migration-text", "sys",
|
||||
"Saved settings were migrated from a previous version of FlightGear. "
|
||||
"If you encounter any problems when using the system, try restoring "
|
||||
"the default settings, before reporting a problem. "
|
||||
"Saved settings can affect the appearance, performance and features of the simulator.");
|
||||
flightgear::modalMessageBox(title, msg);
|
||||
// we can't inform the user yet, becuase embedded resources and the locale
|
||||
// are not done. So we set a flag and check it once those things are done.
|
||||
fgSetBool("/sim/autosave-migration/did-migrate", true);
|
||||
}
|
||||
|
||||
// Load user settings from the autosave file (normally in $FG_HOME)
|
||||
|
|
|
@ -231,11 +231,11 @@ FGLocale::selectLanguage(const char *language)
|
|||
|
||||
loadResource("tips");
|
||||
|
||||
if (!_currentLocale)
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||
"System locale not found or no internationalization settings specified in defaults.xml. Using default (en)." );
|
||||
return false;
|
||||
_inited = true;
|
||||
if (!_currentLocale && !_currentLocaleString.empty()) {
|
||||
SG_LOG(SG_GENERAL, SG_WARN,
|
||||
"System locale not found or no internationalization settings specified in defaults.xml. Using default (en).");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -347,6 +347,7 @@ FGLocale::getLocalizedString(SGPropertyNode *localeNode, const char* id, const c
|
|||
std::string
|
||||
FGLocale::getLocalizedString(const char* id, const char* resource, const char* Default)
|
||||
{
|
||||
assert(_inited);
|
||||
if (id && resource)
|
||||
{
|
||||
std::string s;
|
||||
|
@ -371,6 +372,7 @@ FGLocale::getLocalizedString(const char* id, const char* resource, const char* D
|
|||
std::string
|
||||
FGLocale::getLocalizedStringWithIndex(const char* id, const char* resource, unsigned int index) const
|
||||
{
|
||||
assert(_inited);
|
||||
if (id && resource) {
|
||||
std::string s;
|
||||
if (_currentLocale) {
|
||||
|
@ -404,6 +406,7 @@ FGLocale::getLocalizedStrings(SGPropertyNode *localeNode, const char* id, const
|
|||
|
||||
size_t FGLocale::getLocalizedStringCount(const char* id, const char* resource) const
|
||||
{
|
||||
assert(_inited);
|
||||
if (_currentLocale) {
|
||||
SGPropertyNode* resourceNode = _currentLocale->getNode("strings",0, true)->getNode(resource);
|
||||
if (resourceNode) {
|
||||
|
@ -427,6 +430,7 @@ size_t FGLocale::getLocalizedStringCount(const char* id, const char* resource) c
|
|||
simgear::PropertyList
|
||||
FGLocale::getLocalizedStrings(const char* id, const char* resource)
|
||||
{
|
||||
assert(_inited);
|
||||
if (id && resource)
|
||||
{
|
||||
if (_currentLocale)
|
||||
|
@ -450,6 +454,7 @@ FGLocale::getLocalizedStrings(const char* id, const char* resource)
|
|||
const char*
|
||||
FGLocale::getDefaultFont(const char* fallbackFont)
|
||||
{
|
||||
assert(_inited);
|
||||
const char* font = nullptr;
|
||||
if (_currentLocale)
|
||||
{
|
||||
|
@ -478,6 +483,7 @@ std::string FGLocale::localizedPrintf(const char* id, const char* resource, ...
|
|||
|
||||
std::string FGLocale::vlocalizedPrintf(const char* id, const char* resource, va_list args)
|
||||
{
|
||||
assert(_inited);
|
||||
std::string format = getLocalizedString(id, resource);
|
||||
int len = ::vsnprintf(nullptr, 0, format.c_str(), args);
|
||||
char* buf = (char*) alloca(len);
|
||||
|
|
|
@ -153,6 +153,8 @@ private:
|
|||
* such part, return a copy of the input string.
|
||||
*/
|
||||
static std::string removeEncodingPart(const std::string& locale);
|
||||
|
||||
bool _inited = false;
|
||||
};
|
||||
|
||||
// global translation wrappers
|
||||
|
|
|
@ -686,6 +686,19 @@ int fgMainInit( int argc, char **argv )
|
|||
SG_LOG(SG_GENERAL, SG_INFO,
|
||||
"EmbeddedResourceManager: selected locale '" << locale << "'");
|
||||
|
||||
if (fgGetBool("/sim/autosave-migration/did-migrate", false)) {
|
||||
// inform the user we did migration. This is the earliest point
|
||||
// we can do it, since now the locale is set
|
||||
auto locale = globals->get_locale();
|
||||
const auto title = locale->getLocalizedString("settings-migration-title", "sys", "Settings migrated");
|
||||
const auto msg = locale->getLocalizedString("settings-migration-text", "sys",
|
||||
"Saved settings were migrated from a previous version of FlightGear. "
|
||||
"If you encounter any problems when using the system, try restoring "
|
||||
"the default settings, before reporting a problem. "
|
||||
"Saved settings can affect the appearance, performance and features of the simulator.");
|
||||
flightgear::modalMessageBox(title, msg);
|
||||
}
|
||||
|
||||
// Copy the property nodes for the menus added by registered add-ons
|
||||
addons::AddonManager::instance()->addAddonMenusToFGMenubar();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue