first release of translation facility
* runtime - loading and translating * design-time - works with *.ts file (pip_tr utility) * compile-time - CMake macro for compile *.ts
This commit is contained in:
53
libs/main/application/pitranslator_p.h
Normal file
53
libs/main/application/pitranslator_p.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Translation private
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef pitranslator_p_H
|
||||
#define pitranslator_p_H
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
class PIIODevice;
|
||||
|
||||
namespace PITranslatorPrivate {
|
||||
|
||||
struct PIP_EXPORT Context {
|
||||
void add(const PIString & in, const PIString & out) { strings[in.hash()] = out; }
|
||||
void add(const PIMap<uint, PIString> & sm);
|
||||
PIMap<uint, PIString> strings;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT Translation {
|
||||
void clear();
|
||||
Context * createContext(const PIString & context);
|
||||
Context * createContext(uint hash);
|
||||
PIString translate(const PIString & in, const PIString & context);
|
||||
bool load(const PIByteArray & data);
|
||||
int count() const;
|
||||
PIByteArray save();
|
||||
PIString lang;
|
||||
PIMap<uint, Context *> contexts;
|
||||
};
|
||||
|
||||
PIP_EXPORT int headerSize();
|
||||
PIP_EXPORT bool checkHeader(PIIODevice * d);
|
||||
PIP_EXPORT void writeHeader(PIIODevice * d);
|
||||
|
||||
} // namespace PITranslatorPrivate
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user