no bug - Bumping Thunderbird l10n changesets r=release a=l10n-bump DONTBUILD
cak -> f37fbac8ae72d3ecd819d6224a519b08ff41e4ca
cy -> 7c9ee1d240d733756ac1d57db603bb7ce1b31ac8
de -> 5c2e50907f9b986e263c6c3ee3cdcc9d61b03b52
dsb -> 9c9c687d8792d2222f2a685e5aae2c7bd6d8cea7
fi -> 9586e6d5a4d441ac0c7df3446bb00ac147aaac47
hsb -> 26cf86464cae9f6bf8d0ea3ba8f97232014c87c9
it -> e80120436229ce8febc8ef5801bea5311a87d941
ka -> 2c4e76a22d27eecfb86f5132141f14ecab10b317
kab -> feea57862cb99cc45be3a9b5fd7f3a372ddc4d87
ko -> eefb1803c26e89273f4f0a3ce3079bc65d362ed8
nl -> 10ca045e001682fb7cf69c16beac98051209c893
pa-IN -> 290f751e36b955ff0820412c880d4995f3d36a5e
pt-BR -> 07f029f2869ba00381a54a402eed642e49b254d5
uk -> f88cf7af88a9d1962f11f073c406486cbb3bfe38
zh-CN -> 59df069c5736df81677f3988278f754b178eafd3
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImportTranslate.h"
int ImportTranslate::m_useTranslator = -1;
bool ImportTranslate::ConvertString(const nsCString& inStr, nsCString& outStr,
bool mimeHeader) {
if (inStr.IsEmpty()) {
outStr = inStr;
return true;
}
nsImportTranslator* pTrans = GetTranslator();
// int maxLen = (int) pTrans->GetMaxBufferSize(inStr.Length());
// int hLen = 0;
nsCString set;
nsCString lang;
if (mimeHeader) {
// add the charset and language
pTrans->GetCharset(set);
pTrans->GetLanguage(lang);
}
// Unfortunately, we didn't implement ConvertBuffer for all translators,
// just ConvertToFile. This means that this data will not always
// be converted to the charset of pTrans. In that case...
// We don't always have the data in the same charset as the current
// translator...
// It is safer to leave the charset and language field blank
set.Truncate();
lang.Truncate();
uint8_t* pBuf;
/*
pBuf = (P_U8) outStr.GetBuffer(maxLen);
if (!pBuf) {
delete pTrans;
return FALSE;
}
pTrans->ConvertBuffer((PC_U8)(PC_S8)inStr, inStr.GetLength(), pBuf);
outStr.ReleaseBuffer();
*/
outStr = inStr;
delete pTrans;
// Now I need to run the string through the mime-header special char
// encoder.
pTrans = new CMHTranslator;
pBuf = new uint8_t[pTrans->GetMaxBufferSize(outStr.Length())];
pTrans->ConvertBuffer((const uint8_t*)(outStr.get()), outStr.Length(), pBuf);
delete pTrans;
outStr.Truncate();
if (mimeHeader) {
outStr = set;
outStr += "'";
outStr += lang;
outStr += "'";
}
outStr += (const char*)pBuf;
delete[] pBuf;
return true;
}
nsImportTranslator* ImportTranslate::GetTranslator(void) {
if (m_useTranslator == -1) {
// get the translator to use...
// CString trans;
// trans.LoadString(IDS_LANGUAGE_TRANSLATION);
m_useTranslator = 0;
// if (!trans.CompareNoCase("iso-2022-jp"))
// gWizData.m_useTranslator = 1;
}
switch (m_useTranslator) {
case 0:
return new nsImportTranslator;
// case 1:
// return new CSJis2JisTranslator;
default:
return new nsImportTranslator;
}
}
nsImportTranslator* ImportTranslate::GetMatchingTranslator(
const char* pCharSet) {
/*
CString jp = "iso-2022-jp";
if (!jp.CompareNoCase(pCharSet))
return new CSJis2JisTranslator;
*/
return nullptr;
}