Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
krename/krename/translitplugin.cpp

107 righe
3.1 KiB

Questo file contiene caratteri Unicode ambigui!

Questo file contiene caratteri Unicode ambigui che possono essere confusi con altri nella tua localizzazione attuale. Se il tuo caso di utilizzo è intenzionale e legittimo, puoi tranquillamente ignorare questo avviso. Usa il pulsante Escape per evidenziare questi caratteri.

//
// C++ Implementation: translitplugin
//
// Description:
//
//
// Author: Dominik Seichter <domseichter@web.de>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "translitplugin.h"
#include "translitplugin.moc"
const TQString TranslitPlugin::m_strUtf8[] = {"а","б","в","г","д","е","ё","ж","з","и",
"й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь",
"э","ю","я",
"А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П",
"Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я",
"á","ä","č","ď","é","ě","í","ľ","ĺ","ň","ó","ô","ř","ŕ","š","ť","ú","ů","ý","ž",
"Á","Ä","Č","Ď","É","Ě","Í","Ľ","Ĺ","Ň","Ó","Ô","Ř","Ŕ","Š","Ť","Ú","Ů","Ý","Ž",TQString()};
const TQString TranslitPlugin::m_strEngl[]= {"a","b","v","g","d","e","yo","zh","z","i",
"j","k","l","m","n","o","p","r","s","t","u","f","h","c","ch","sh","sh","","y","",
"e","yu","ya",
"A","B","V","G","D","E","Yo","Zh","Z","I","J","K","L","M","N","O","P",
"R","S","T","U","F","H","C","Ch","Sh","Sh","","Y","","E","Yu","Ya",
"a","a","c","d","e","e","i","l","l","n","o","o","r","r","s","t","u","u","y","z",
"A","A","C","D","E","E","I","L","L","N","O","O","R","R","S","T","U","U","Y","Z",TQString()};
const TQString TranslitPlugin::getName() const
{
return i18n("Transliteration Plugin");
}
const TQString TranslitPlugin::getAccelName() const
{
return i18n("&Transliteration Plugin");
}
const TQPixmap TranslitPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "fonts", KIcon::Small );
}
const int TranslitPlugin::type() const
{
return TYPE_FINAL_FILENAME;
}
void TranslitPlugin::drawInterface( TQWidget* w, TQVBoxLayout* l )
{
TQLabel* label = new TQLabel(
i18n("<qt>This plugin transliterates names written with non-english characters.</qt>"), w );
l->addWidget( label );
label = new TQLabel( "<qt><b>WARNING! THIS PLUGIN IS EXPERIMENTAL AND MIGHT CAUSE LOSS OF DATA!</b></qt>", w );
l->addWidget( label );
}
void TranslitPlugin::finished()
{
}
void TranslitPlugin::fillStructure()
{
}
bool TranslitPlugin::checkError()
{
return true;
}
TQString TranslitPlugin::processFile( BatchRenamer*, int, TQString token, int )
{
TQString output = translit( token );
return output; // no error
}
TQString TranslitPlugin::translit(const TQString & tqunicoded)
{
int i;
TQString transed = "";
for (i=0; i<(int)tqunicoded.length(); i++) {
TQString charIn = tqunicoded.mid(i, 1);
if (m_mapFromUTF8[charIn.utf8()]) {
TQString charTrans = m_mapFromUTF8[charIn.utf8()];
transed.append(charTrans);
} else {
transed.append(charIn);
}
}
return transed;
}
TranslitPlugin::TranslitPlugin() {
// Initialize transliteration map
int i;
for (i=0; m_strUtf8[i]!=TQString(); i++) {
TQString src = m_strUtf8[i];
TQString dst = m_strEngl[i];
m_mapFromUTF8[src] = dst;
}
}