~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Gui/Language/Translator.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de>              *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#ifndef GUI_TRANSLATOR_H
 
25
#define GUI_TRANSLATOR_H
 
26
 
 
27
#ifndef __Qt4All__
 
28
# include <Gui/Qt4All.h>
 
29
#endif
 
30
 
 
31
#include <string>
 
32
#include <map>
 
33
#include <list>
 
34
 
 
35
namespace Gui {
 
36
 
 
37
typedef std::list<std::string> TStringList;
 
38
 
 
39
/**
 
40
 * The Translator class uses Qt's QTranslator objects to change the language of the application
 
41
 * on the fly.
 
42
 * For more details see the \link i18n.html Internationalization with FreeCAD \endlink
 
43
 * documentation.
 
44
 *
 
45
 * \author Werner Mayer
 
46
 */
 
47
class TranslatorP;
 
48
class GuiExport Translator : public QObject
 
49
{
 
50
    Q_OBJECT
 
51
 
 
52
public:
 
53
    /** @name singleton stuff */
 
54
    //@{
 
55
    /// Creates an instance
 
56
    static Translator* instance(void);
 
57
    /// Destroys the instance
 
58
    static void destruct (void);
 
59
    //@}
 
60
 
 
61
    /** Activates the specified language \a lang if available. */
 
62
    void activateLanguage (const char* lang);
 
63
    /* Reloads the translators */
 
64
    void refresh();
 
65
    /** Returns the currently installed language. If no language is installed an empty string is returned. */
 
66
    std::string activeLanguage() const;
 
67
    /** Returns a list of supported languages. */
 
68
    TStringList supportedLanguages() const;
 
69
    /** Adds a path where localization files can be found */
 
70
    void addPath(const QString& path);
 
71
 
 
72
private:
 
73
    Translator();
 
74
    ~Translator();
 
75
    void removeTranslators();
 
76
    QStringList directories() const;
 
77
    void installQMFiles(const QDir& dir, const char* locale);
 
78
 
 
79
private:
 
80
    static Translator* _pcSingleton;
 
81
    TranslatorP* d;
 
82
};
 
83
 
 
84
} // namespace Gui
 
85
 
 
86
#endif // GUI_TRANSLATOR_H