• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • scripts
translator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "translator.h"
16 #include "scripting/parley.h"
17 
18 #include <KDebug>
19 
20 Translator::Translator()
21 {
22 }
23 
24 Translator::Translator( QObject * parent )
25  : m_parent(parent)
26 {
27 }
28 
29 Translator::~Translator()
30 {
31 }
32 
33 void Translator::addTranslation ( QString word, QString fromLanguage, QString toLanguage, QString translation )
34 {
35  if ( word.trimmed() == "" ) return;
36 
37  QString t = word+fromLanguage+toLanguage;
38  kDebug() << "Translation for " << word << "in cache: " << m_translations.contains ( t );
39  if ( !m_translations.contains ( t ) ) {
40  m_translations[t] = new QSet<QString>();
41  }
42  m_translations[t]->insert ( translation.simplified() );
43 }
44 
45 QSet<QString>* Translator::getTranslation ( QString word, QString fromLanguage, QString toLanguage )
46 {
47  if (word.isEmpty() || fromLanguage.isEmpty() || toLanguage.isEmpty()) return 0;
48 
49  QString t = word+fromLanguage+toLanguage;
50  kDebug() << "Fetch translation " << word << "(" << fromLanguage << "to" << toLanguage << ")"
51  << "already in cache:" << m_translations.contains(t);
52  if (!m_translations.contains(t)) {
53  Scripting::Parley * p = dynamic_cast<Scripting::Parley*>(m_parent);
54  if (p) {
55  p->callTranslateWord(word,fromLanguage,toLanguage);
56  }
57  }
58 
59  if ( m_translations.contains ( t ) )
60  return m_translations.value ( t );
61  else
62  return 0;
63 }
Scripting::Parley::callTranslateWord
void callTranslateWord(const QString &word, const QString &fromLanguage, const QString &toLanguage)
Definition: parley.cpp:54
QObject
parley.h
Translator::addTranslation
void addTranslation(QString word, QString fromLanguage, QString toLanguage, QString translation)
Stores the translation of word from language fromLanguage, to language toLanguage.
Definition: translator.cpp:33
Translator::~Translator
~Translator()
Definition: translator.cpp:29
Scripting::Parley
Parley scripting class (main entry point of a Parley Kross script)
Definition: parley.h:151
Translator::Translator
Translator()
Definition: translator.cpp:20
translator.h
Translator::getTranslation
QSet< QString > * getTranslation(QString word, QString fromLanguage, QString toLanguage)
Returns a QStringList with all the translations of word from fromLanguage to toLanguage.
Definition: translator.cpp:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal