Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Allow for multilingual FX Help tooltips by jpturcotte (modified) (#1931)

shun-iwasawa5b724a61d7de
diff --git a/toonz/sources/common/tsystem/tfilepath_io.cpp b/toonz/sources/common/tsystem/tfilepath_io.cpp
index 3c9d0fd85..45d4df9e0 100644
--- a/toonz/sources/common/tsystem/tfilepath_io.cpp
+++ b/toonz/sources/common/tsystem/tfilepath_io.cpp
@@ -31,8 +31,12 @@ FILE *fopen(const TFilePath &fp, string mode) {
return pFile;
}
-Tifstream::Tifstream(const TFilePath &fp)
- : ifstream(m_file = fopen(fp, "rb")) {}
+Tifstream::Tifstream(const TFilePath &fp) : ifstream(m_file = fopen(fp, "rb")) {
+ // manually set the fail bit here, since constructor ifstream::ifstream(FILE*)
+ // does not so even if the argument is null pointer.
+ // the state will be refered in "TIStream::operator bool()" ( in tstream.cpp )
+ if (!m_file) setstate(failbit);
+}
Tifstream::~Tifstream() {
if (m_file) {
@@ -47,7 +51,12 @@ void Tifstream::close() {
}
Tofstream::Tofstream(const TFilePath &fp, bool append_existing)
- : ofstream(m_file = fopen(fp, append_existing ? "ab" : "wb")) {}
+ : ofstream(m_file = fopen(fp, append_existing ? "ab" : "wb")) {
+ // manually set the fail bit here, since constructor ofstream::ofstream(FILE*)
+ // does not so even if the argument is null pointer.
+ // the state will be refered in "TOStream::operator bool()" ( in tstream.cpp )
+ if (!m_file) setstate(failbit);
+}
Tofstream::~Tofstream() {
if (m_file) {
diff --git a/toonz/sources/toonzqt/fxsettings.cpp b/toonz/sources/toonzqt/fxsettings.cpp
index b72f579f0..571480ef1 100644
--- a/toonz/sources/toonzqt/fxsettings.cpp
+++ b/toonz/sources/toonzqt/fxsettings.cpp
@@ -15,6 +15,7 @@
#include "toutputproperties.h"
#include "pluginhost.h"
#include "tenv.h"
+#include "tsystem.h"
#include "toonz/tcamera.h"
#include "toonz/toonzfolders.h"
@@ -822,6 +823,7 @@ void ParamsPageSet::createControls(const TFxP &fx, int index) {
TFilePath fp = ToonzFolder::getProfileFolder() + "layouts" + "fxs" +
(fx->getFxType() + ".xml");
+
TIStream is(fp);
if (!is) return;
@@ -904,8 +906,18 @@ void ParamsPageSet::openHelpFile() {
// if (m_helpCommand != "")
// commandString += m_helpCommand + " ";
- TFilePath helpFp =
- TEnv::getStuffDir() + TFilePath("doc") + TFilePath(m_helpFilePath);
+ // Get UI language as set in "Preferences"
+ QString currentLanguage = Preferences::instance()->getCurrentLanguage();
+ std::string helpDocLang = currentLanguage.toStdString();
+
+ // Assume associated language subdir exists
+ TFilePath helpFp = TEnv::getStuffDir() + "doc" + helpDocLang + m_helpFilePath;
+
+ // Verify subdir exists; if not, default to standard doc dir
+ if (!TFileStatus(helpFp).doesExist()) {
+ helpFp = TEnv::getStuffDir() + "doc" + m_helpFilePath;
+ }
+
// commandString +=
// QString::fromStdWString(helpFp.getWideString()).toStdString();
// QString command = QString::fromStdString(m_helpFilePath);