Seamly2D
Code documentation
qmutranslation.cpp
Go to the documentation of this file.
1 /***************************************************************************************************
2  **
3  ** Copyright (C) 2014 Roman Telezhynskyi <dismine(at)gmail.com>
4  **
5  ** Permission is hereby granted, free of charge, to any person obtaining a copy of this
6  ** software and associated documentation files (the "Software"), to deal in the Software
7  ** without restriction, including without limitation the rights to use, copy, modify,
8  ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9  ** permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  **
11  ** The above copyright notice and this permission notice shall be included in all copies or
12  ** substantial portions of the Software.
13  **
14  ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15  ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16  ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17  ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  **
20  ******************************************************************************************************/
21 
22 #include "qmutranslation.h"
23 
24 #include <QByteArray>
25 #include <QCoreApplication>
26 
27 namespace qmu
28 {
29 
30 //---------------------------------------------------------------------------------------------------------------------
31 QmuTranslation QmuTranslation::translate(const QString &context, const QString &sourceText,
32  const QString &disambiguation, int n)
33 {
34  if (n < 0)
35  {
36  n = -1;
37  }
38  QmuTranslation t(context, sourceText, disambiguation, n);
39  return t;
40 }
41 
42 //---------------------------------------------------------------------------------------------------------------------
44  :mcontext(QString()), msourceText(QString()), mdisambiguation(QString()), mn(-1)
45 {}
46 
47 //---------------------------------------------------------------------------------------------------------------------
48 QmuTranslation::QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation, int n)
49  :mcontext(context), msourceText(sourceText), mdisambiguation(disambiguation), mn(n)
50 {}
51 
52 //---------------------------------------------------------------------------------------------------------------------
54 {
55  if ( &tr == this )
56  {
57  return *this;
58  }
59  this->mcontext = tr.getMcontext();
60  this->msourceText = tr.getMsourceText();
62  this->mn = tr.getN();
63  return *this;
64 }
65 
66 //---------------------------------------------------------------------------------------------------------------------
68  :mcontext(tr.getMcontext()), msourceText(tr.getMsourceText()), mdisambiguation(tr.getMdisambiguation()),
69  mn(tr.getN())
70 {}
71 
72 //---------------------------------------------------------------------------------------------------------------------
74 {
75  return QCoreApplication::translate(mcontext.toUtf8().constData(), msourceText.toUtf8().constData(),
76  mdisambiguation.toUtf8().constData(), mn);
77 }
78 
79 } // namespace qmu
QString getMsourceText() const
QString getMdisambiguation() const
QmuTranslation & operator=(const QmuTranslation &tr)
QString translate() const
QString getMcontext() const
Namespace for mathematical applications.
The VTranslation class help store string for translation.
#define translate(context, source)
Definition: vcmdexport.cpp:41