2014-12-18 18:40:49 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It 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 General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-12-18 18:40:49 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2015-10-03 13:16:42 +00:00
|
|
|
Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
2014-12-18 18:40:49 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "lang.h"
|
|
|
|
|
|
|
|
LangString langCounted(ushort key0, ushort tag, float64 value) { // current lang dependent
|
|
|
|
int v = qFloor(value);
|
|
|
|
QString sv;
|
|
|
|
ushort key = key0;
|
|
|
|
if (v != qCeil(value)) {
|
|
|
|
key += 2;
|
|
|
|
sv = QString::number(value);
|
|
|
|
} else {
|
|
|
|
if (v == 1) {
|
|
|
|
key += 1;
|
|
|
|
} else if (v) {
|
|
|
|
key += 2;
|
|
|
|
}
|
|
|
|
sv = QString::number(v);
|
|
|
|
}
|
|
|
|
while (key > key0) {
|
|
|
|
LangString v = lang(LangKey(key));
|
|
|
|
if (!v.isEmpty()) return v.tag(tag, sv);
|
|
|
|
--key;
|
|
|
|
}
|
|
|
|
return lang(LangKey(key0)).tag(tag, sv);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &LangLoader::errors() const {
|
|
|
|
if (_errors.isEmpty() && !_err.isEmpty()) {
|
|
|
|
_errors = _err.join('\n');
|
|
|
|
}
|
|
|
|
return _errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &LangLoader::warnings() const {
|
|
|
|
if (!_checked) {
|
|
|
|
for (int32 i = 0; i < lngkeys_cnt; ++i) {
|
|
|
|
if (!_found[i]) {
|
|
|
|
_warn.push_back(qsl("No value found for key '%1'").arg(langKeyName(LangKey(i))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_checked = true;
|
|
|
|
}
|
|
|
|
if (_warnings.isEmpty() && !_warn.isEmpty()) {
|
|
|
|
_warnings = _warn.join('\n');
|
|
|
|
}
|
|
|
|
return _warnings;
|
|
|
|
}
|
2015-01-05 20:19:05 +00:00
|
|
|
|
2015-01-06 12:05:53 +00:00
|
|
|
void LangLoader::foundKeyValue(LangKey key) {
|
|
|
|
if (key < lngkeys_cnt) {
|
|
|
|
_found[key] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-05 20:19:05 +00:00
|
|
|
QString Translator::translate(const char *context, const char *sourceText, const char *disambiguation, int n) const {
|
2015-06-27 13:02:00 +00:00
|
|
|
if (qstr("QMenuBar") == context) {
|
|
|
|
if (qstr("Services") == sourceText) return lang(lng_mac_menu_services);
|
|
|
|
if (qstr("Hide %1") == sourceText) return lng_mac_menu_hide_telegram(lt_telegram, qsl("%1"));
|
|
|
|
if (qstr("Hide Others") == sourceText) return lang(lng_mac_menu_hide_others);
|
|
|
|
if (qstr("Show All") == sourceText) return lang(lng_mac_menu_show_all);
|
|
|
|
if (qstr("Preferences...") == sourceText) return lang(lng_mac_menu_preferences);
|
|
|
|
if (qstr("Quit %1") == sourceText) return lng_mac_menu_quit_telegram(lt_telegram, qsl("%1"));
|
|
|
|
if (qstr("About %1") == sourceText) return lng_mac_menu_about_telegram(lt_telegram, qsl("%1"));
|
2015-01-05 20:19:05 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2015-06-27 13:02:00 +00:00
|
|
|
if (qstr("QWidgetTextControl") == context || qstr("QLineEdit") == context) {
|
|
|
|
if (qstr("&Undo") == sourceText) return lang((cPlatform() == dbipWindows) ? lng_wnd_menu_undo : ((cPlatform() == dbipMac) ? lng_mac_menu_undo : lng_linux_menu_undo));
|
|
|
|
if (qstr("&Redo") == sourceText) return lang((cPlatform() == dbipWindows) ? lng_wnd_menu_redo : ((cPlatform() == dbipMac) ? lng_mac_menu_redo : lng_linux_menu_redo));
|
|
|
|
if (qstr("Cu&t") == sourceText) return lang(lng_mac_menu_cut);
|
|
|
|
if (qstr("&Copy") == sourceText) return lang(lng_mac_menu_copy);
|
|
|
|
if (qstr("&Paste") == sourceText) return lang(lng_mac_menu_paste);
|
|
|
|
if (qstr("Delete") == sourceText) return lang(lng_mac_menu_delete);
|
|
|
|
if (qstr("Select All") == sourceText) return lang(lng_mac_menu_select_all);
|
2015-01-05 20:19:05 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2015-06-27 13:02:00 +00:00
|
|
|
if (qstr("QUnicodeControlCharacterMenu") == context) {
|
|
|
|
if (qstr("Insert Unicode control character") == sourceText) return lang(lng_menu_insert_unicode);
|
2015-02-16 15:30:32 +00:00
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
return QString();
|
2015-01-05 20:19:05 +00:00
|
|
|
}
|