# Japanese translation and ts (po) file

#1

I use Avogadro only on Windows (Japanese version).
I tried to open a molecular file which name or path included Japanese
letters
(hiragana, katakana or kanji) on Avogadro, but a message box such that
"Reading molecular file faild: C:/…/(Japanese letters)/…/molecule.cml"
appeared, and failed to open.

For a file which name or path consists of only roman letters, things went
well !

It is not only for my own built Avogadro (with Qt 4.6.3 opensource and VC
2005 EE on (stale) Win XP), but also for installed application with a

This phenomenon also occurred for two different Win XP machines.

On the other hand, avogadro application which built from the edited sources
(as described in the previous mail) can read a molecular file which name or
path include Japanese letters without difficulties !

I also found that
QTextCodec::setCodecForCStrings(QTextCodec::codecForLoocale());
QTextCodec::SetCodecForTr(QTextCodec::codecForLocale());
are not nessesary.
But
std::locale::global(std::locale(“japanese”));
seems to be necessary.

I guess this phenomenon may not come from avogadro, but from other
libraries ( openbabel etc. ), or compatibility of avogadro or libraries
with Windows.

Thank you very much, Prof. Geoff !

Regards.

iwao

#2

I had updated the ts file with Qt linguist for my own usage.

Can I contribute with Qt ts file (or converted GNU GetText po file), instead of inputting on the Launchpad ?

Of course. Launchpad will actually take a PO upload, but if you’d rather just send it to me, I’ll handle the merge.

This would be very greatly appreciated, since I’m working on a 1.2 release for the end of the summer.

Thanks very much!
-Geoff

#3

Hello Professor Geoff.

I would prefer to send my ts file to you, since I don’t know how to upload

In this connection I have one more question.

The original Avogadro apparently can not handle multibytes characters in a
file name and a directory path name.
I think it is necessary to add some source codes to handle Japanese
characters.

It might be same for Chinese version. How did you deal?

In my experience the following edited codes seems to work well in a
Japanese circumstance.

  :


int main(int argc, char *argv[])
{

  :


Application app(argc, argv):

QString versionInfo = …

  :


}

I want to translate Avogadro 1.2 into Japanese after completion of your
work.

Regards.

iwao

#4

The original Avogadro apparently can not handle multibytes characters in a file name and a directory path name.
I think it is necessary to add some source codes to handle Japanese characters.

It might be same for Chinese version. How did you deal?

My Chinese students didn’t seem to have problems, but I’ll definitely investigate your suggestion as a patch.

This shouldn’t be necessary. Does Avogadro not pick up the locale?

-Geoff

#5

std::locale::global(std::locale(“japanese”));

Can you try a slight patch which I think would be better (i.e., not everyone uses Japanese) to see if it fixes the problem with Kanji filenames on Windows for you?

QString lang = QLocale::languageToString(QLocale::system().language());
std::locale::global(std::locale(lang.toLocal8Bit().constData()));

Unfortunately, I don’t have either Windows or a Japanese system to see if this works. My guess is that this will solve your problem by getting the system locale from Qt.

Thanks and best regards,
-Geoff

#6

QString lang = QLocale::languageToString(QLocale::system().language());
std::locale::global(std::locale(lang.toLocal8Bit().constData()));

std::locale::global(std::locale(“japanese”));

in the first line of “int main(int argc, char *argv[])” function in avogadro
/src/main.cpp.

I ran “nmake avogadro-app” on Microsoft Visual Studio 2005 command prompt