mirror of
https://github.com/wownero/wownero.git
synced 2026-10-17 23:51:37 +02:00
remove translations
This commit is contained in:
@@ -410,7 +410,6 @@ endif()
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
enable_testing()
|
||||
|
||||
option(BUILD_TRANSLATIONS "Build translations using lrelease (Qt)" OFF)
|
||||
option(BUILD_DOCUMENTATION "Build the Doxygen documentation." ON)
|
||||
option(BUILD_TESTS "Build tests." OFF)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@@ -628,20 +627,6 @@ function (monero_add_library_with_deps)
|
||||
PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
|
||||
endfunction ()
|
||||
|
||||
if(BUILD_TRANSLATIONS)
|
||||
# Generate header for embedded translations
|
||||
# use target toolchain if depends, otherwise use the
|
||||
# lrelease and lupdate binaries from the host
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(generate_translations_header
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/translations"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/translations"
|
||||
STAMP_DIR ${LRELEASE_PATH}
|
||||
CMAKE_ARGS -DLRELEASE_PATH=${LRELEASE_PATH}
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "")
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
|
||||
endif()
|
||||
|
||||
add_subdirectory(external)
|
||||
|
||||
# Final setup for libunbound
|
||||
|
||||
@@ -21,7 +21,6 @@ Portions Copyright (c) 2012-2013 The Cryptonote developers.
|
||||
- [Guix builds](#guix-builds)
|
||||
- [Installing Monero from a package](#installing-monero-from-a-package)
|
||||
- [Running monerod](#running-monerod)
|
||||
- [Internationalization](#internationalization)
|
||||
- [Using Tor](#using-tor)
|
||||
- [Pruning](#pruning)
|
||||
- [Debugging](#debugging)
|
||||
@@ -154,7 +153,6 @@ The following table summarizes the tools and libraries required to build. A few
|
||||
| ccache | any | NO | `ccache` | `ccache` | `ccache` | `ccache` | YES | Compil. cache |
|
||||
| Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | `doxygen` | YES | Documentation |
|
||||
| Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | `graphviz` | YES | Documentation |
|
||||
| lrelease | ? | NO | `qttools5-dev-tools` | `qt5-tools` | `qt5-tools` | `qt5-linguist` | YES | Translations |
|
||||
| libhidapi | ? | NO | `libhidapi-dev` | `hidapi` | `hidapi-devel` | `hidapi-devel` | YES | Hardware wallet |
|
||||
| libusb | ? | NO | `libusb-1.0-0-dev` | `libusb` | `libusb-devel` | `libusb1-devel` | YES | Hardware wallet |
|
||||
| libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | `protobuf-devel` | YES | Hardware wallet |
|
||||
@@ -163,23 +161,23 @@ The following table summarizes the tools and libraries required to build. A few
|
||||
Install all dependencies at once on Debian/Ubuntu:
|
||||
|
||||
```
|
||||
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind-dev libreadline-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl
|
||||
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind-dev libreadline-dev libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl
|
||||
```
|
||||
|
||||
Install all dependencies at once on Arch:
|
||||
```
|
||||
sudo pacman -Syu --needed base-devel cmake boost boost-libs openssl zeromq unbound libsodium libunwind readline python ccache doxygen graphviz qt5-tools hidapi libusb protobuf
|
||||
sudo pacman -Syu --needed base-devel cmake boost boost-libs openssl zeromq unbound libsodium libunwind readline python ccache doxygen graphviz hidapi libusb protobuf
|
||||
```
|
||||
|
||||
Install all dependencies at once on Fedora:
|
||||
```
|
||||
sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel unbound-devel libsodium-devel libunwind-devel readline-devel ccache doxygen graphviz qt5-linguist hidapi-devel libusb1-devel protobuf-devel protobuf-compiler
|
||||
sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel unbound-devel libsodium-devel libunwind-devel readline-devel ccache doxygen graphviz hidapi-devel libusb1-devel protobuf-devel protobuf-compiler
|
||||
```
|
||||
|
||||
Install all dependencies at once on openSUSE:
|
||||
|
||||
```
|
||||
sudo zypper ref && sudo zypper in cppzmq-devel libboost_chrono-devel libboost_date_time-devel libboost_filesystem-devel libboost_locale-devel libboost_program_options-devel libboost_regex-devel libboost_serialization-devel libboost_system-devel libboost_thread-devel libsodium-devel libunwind-devel unbound-devel cmake doxygen ccache fdupes gcc-c++ libevent-devel libopenssl-devel pkgconf-pkg-config readline-devel libqt5-qttools-devel patterns-devel-C-C++-devel_C_C++
|
||||
sudo zypper ref && sudo zypper in cppzmq-devel libboost_chrono-devel libboost_date_time-devel libboost_filesystem-devel libboost_locale-devel libboost_program_options-devel libboost_regex-devel libboost_serialization-devel libboost_system-devel libboost_thread-devel libsodium-devel libunwind-devel unbound-devel cmake doxygen ccache fdupes gcc-c++ libevent-devel libopenssl-devel pkgconf-pkg-config readline-devel patterns-devel-C-C++-devel_C_C++
|
||||
```
|
||||
|
||||
Install all dependencies at once on macOS with the provided Brewfile:
|
||||
@@ -542,10 +540,6 @@ To run as a systemd service, copy [monerod.service](utils/systemd/monerod.servic
|
||||
|
||||
If you're on Mac, you may need to add the `--max-concurrency 1` option to monero-wallet-cli, and possibly monerod, if you get crashes refreshing.
|
||||
|
||||
## Internationalization
|
||||
|
||||
See [README.i18n.md](docs/README.i18n.md).
|
||||
|
||||
## Using Tor
|
||||
|
||||
> There is a new, still experimental, [integration with Tor](docs/ANONYMITY_NETWORKS.md). The feature allows connecting over IPv4 and Tor simultaneously - IPv4 is used for relaying blocks and relaying transactions received by peers whereas Tor is used solely for relaying transactions received over local RPC. This provides privacy and better protection against surrounding node (sybil) attacks.
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
Monero daemon internationalization
|
||||
==================================
|
||||
|
||||
The Monero command line tools can be translated in various languages. If you wish to contribute and need help/support, contact the [Monero Localization Workgroup on Taiga](https://taiga.getmonero.org/project/erciccione-monero-localization/) or come chat on `#monero-translations` (Libera/IRC, riot/matrix, MatterMost)
|
||||
|
||||
In order to use the same translation workflow as the [Monero Core GUI](https://github.com/monero-project/monero-gui), they use Qt Linguist translation files. However, to avoid the dependencies on Qt this normally implies, they use a custom loader to read those files at runtime.
|
||||
|
||||
### Tools for translators
|
||||
|
||||
In order to create, update or build translations files, you need to have Qt tools installed. For translating, you need either the **Qt Linguist GUI** ([part of Qt Creator](https://www.qt.io/download) or a [3rd-party standalone version](https://github.com/lelegard/qtlinguist-installers/releases)), or another tool that supports Qt ts files, such as Transifex. The files are XML, so they can be edited in any plain text editor if needed.
|
||||
|
||||
### Creating / modifying translations
|
||||
|
||||
You do not need anything from Qt in order to use the final translations.
|
||||
|
||||
To update ts files after changing source code:
|
||||
|
||||
```bash
|
||||
./utils/translations/update-translations.sh
|
||||
```
|
||||
|
||||
To add a new language, eg Spanish (ISO code es):
|
||||
|
||||
```bash
|
||||
cp translations/monero.ts translations/monero_es.ts
|
||||
```
|
||||
|
||||
To edit translations for Spanish:
|
||||
|
||||
```bash
|
||||
linguist translations/monero_es.ts
|
||||
```
|
||||
|
||||
To build translations after modifying them:
|
||||
|
||||
```bash
|
||||
./utils/translations/build-translations.sh
|
||||
```
|
||||
|
||||
To test a translation:
|
||||
|
||||
```bash
|
||||
LANG=es ./build/release/bin/monero-wallet-cli
|
||||
```
|
||||
|
||||
To add new translatable strings in the source code:
|
||||
|
||||
Use the `tr(string)` function if possible. If the code is in a class, and this class doesn't already have a `tr()` static function, add one, which uses a context named after what `lupdate` uses for the context, usually the fully qualified class name (eg, `cryptonote::simple_wallet`). If you need to use `tr()` in code that's not in a class, you can use the fully qualified version (eg, `simple_wallet::tr`) of the one matching the context you want. Use `QT_TRANSLATE_NOOP(string)` if you want to specify a context manually.
|
||||
|
||||
If you're getting messages of the form:
|
||||
|
||||
```
|
||||
Class 'cryptonote::simple_wallet' lacks Q_OBJECT macro
|
||||
```
|
||||
|
||||
all is fine, we don't actually need that here.
|
||||
@@ -36,7 +36,6 @@ set(common_sources
|
||||
error.cpp
|
||||
expect.cpp
|
||||
util.cpp
|
||||
i18n.cpp
|
||||
notify.cpp
|
||||
password.cpp
|
||||
perf_timer.cpp
|
||||
@@ -67,10 +66,6 @@ if (STACK_TRACE_USE_WRAP)
|
||||
target_compile_definitions(obj_common PRIVATE STACK_TRACE_USE_WRAP)
|
||||
endif()
|
||||
|
||||
if(BUILD_TRANSLATIONS)
|
||||
add_dependencies(obj_common generate_translations_header)
|
||||
endif()
|
||||
|
||||
target_link_libraries(common
|
||||
PUBLIC
|
||||
cncrypto
|
||||
|
||||
@@ -1,341 +0,0 @@
|
||||
// Copyright (c) 2014-2024, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "file_io_utils.h"
|
||||
#include "common/i18n.h"
|
||||
|
||||
#if __has_include("translation_files.h")
|
||||
#include "translation_files.h"
|
||||
#else
|
||||
static bool find_embedded_file(const std::string &name, std::string &data) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "i18n"
|
||||
|
||||
#define MAX_LANGUAGE_SIZE 16
|
||||
|
||||
static const unsigned char qm_magic[16] = {0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95, 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd};
|
||||
|
||||
static std::map<std::string,std::string> i18n_entries;
|
||||
|
||||
/* Logging isn't initialized yet when this is run */
|
||||
/* add std::flush, because std::endl doesn't seem to flush, contrary to expected */
|
||||
// #define i18n_log(x) do { std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl; std::cout << std::flush; } while(0)
|
||||
#define i18n_log(x) ((void)0)
|
||||
|
||||
std::string i18n_get_language()
|
||||
{
|
||||
const char *e;
|
||||
|
||||
e = getenv("LANG");
|
||||
i18n_log("LANG=" << e);
|
||||
if (!e || !*e) {
|
||||
e = getenv("LC_ALL");
|
||||
i18n_log("LC_ALL=" << e);
|
||||
}
|
||||
if (!e || !*e)
|
||||
e = "en";
|
||||
|
||||
std::string language = e;
|
||||
language = language.substr(0, language.find("."));
|
||||
language = language.substr(0, language.find("@"));
|
||||
|
||||
// check valid values
|
||||
for (char c: language)
|
||||
if (!strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@", c))
|
||||
return "en";
|
||||
|
||||
std::transform(language.begin(), language.end(), language.begin(), tolower);
|
||||
if (language.size() > MAX_LANGUAGE_SIZE)
|
||||
{
|
||||
i18n_log("Language from LANG/LC_ALL suspiciously long, defaulting to en");
|
||||
return "en";
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
static uint32_t be32(const unsigned char *data)
|
||||
{
|
||||
return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||
}
|
||||
|
||||
static std::string utf16(const unsigned char *data, uint32_t len)
|
||||
{
|
||||
std::string s;
|
||||
while (len >= 2) {
|
||||
uint32_t code = (data[0] << 8) | data[1];
|
||||
data += 2;
|
||||
len -= 2;
|
||||
if (code >= 0xd800 && code <= 0xdbfff && len >= 2) {
|
||||
uint32_t next = (data[0] << 8) | data[1];
|
||||
if (next >= 0xdc00 && next <= 0xdfff) {
|
||||
code = (code << 10) + next - 0x35dfc00;
|
||||
data += 2;
|
||||
len -= 2;
|
||||
}
|
||||
}
|
||||
if (code <= 0x7f) {
|
||||
s += (char)code;
|
||||
}
|
||||
else if (code <= 0x7ff) {
|
||||
s += 0xc0 | (code >> 6);
|
||||
s += 0x80 | (code & 0x3f);
|
||||
}
|
||||
else if (code <= 0xffff) {
|
||||
s += 0xe0 | (code >> 12);
|
||||
s += 0x80 | ((code >> 6) & 0x3f);
|
||||
s += 0x80 | (code & 0x3f);
|
||||
}
|
||||
else {
|
||||
s += 0xf0 | (code >> 18);
|
||||
s += 0x80 | ((code >> 12) & 0x3f);
|
||||
s += 0x80 | ((code >> 6) & 0x3f);
|
||||
s += 0x80 | (code & 0x3f);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::string utf8(const unsigned char *data, uint32_t len)
|
||||
{
|
||||
/* assume well formedness */
|
||||
return std::string((const char *)data,len);
|
||||
}
|
||||
|
||||
int i18n_set_language(const char *directory, const char *base, std::string language)
|
||||
{
|
||||
std::string filename, contents;
|
||||
const unsigned char *data;
|
||||
size_t datalen;
|
||||
size_t idx;
|
||||
unsigned char chunk_type;
|
||||
uint32_t chunk_size;
|
||||
uint32_t num_messages = (uint32_t)-1;
|
||||
uint32_t messages_idx = (uint32_t)-1;
|
||||
uint32_t offsets_idx = (uint32_t)-1;
|
||||
std::string translation, source, context;
|
||||
|
||||
i18n_log("i18n_set_language(" << directory << "," << base << ")");
|
||||
if (!directory || !base)
|
||||
return -1;
|
||||
|
||||
if (language.empty())
|
||||
language = i18n_get_language();
|
||||
filename = std::string(directory) + "/" + base + "_" + language + ".qm";
|
||||
i18n_log("Loading translations for language " << language);
|
||||
|
||||
boost::system::error_code ignored_ec;
|
||||
if (boost::filesystem::exists(filename, ignored_ec)) {
|
||||
if (!epee::file_io_utils::load_file_to_string(filename, contents)) {
|
||||
i18n_log("Failed to load translations file: " << filename);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
i18n_log("Translations file not found: " << filename);
|
||||
filename = std::string(base) + "_" + language + ".qm";
|
||||
if (!find_embedded_file(filename, contents)) {
|
||||
i18n_log("Embedded translations file not found: " << filename);
|
||||
const char *underscore = strchr(language.c_str(), '_');
|
||||
if (underscore) {
|
||||
std::string fallback_language = std::string(language, 0, underscore - language.c_str());
|
||||
filename = std::string(directory) + "/" + base + "_" + fallback_language + ".qm";
|
||||
i18n_log("Loading translations for language " << fallback_language);
|
||||
if (boost::filesystem::exists(filename, ignored_ec)) {
|
||||
if (!epee::file_io_utils::load_file_to_string(filename, contents)) {
|
||||
i18n_log("Failed to load translations file: " << filename);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
i18n_log("Translations file not found: " << filename);
|
||||
filename = std::string(base) + "_" + fallback_language + ".qm";
|
||||
if (!find_embedded_file(filename, contents)) {
|
||||
i18n_log("Embedded translations file not found: " << filename);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data = (const unsigned char*)contents.c_str();
|
||||
datalen = contents.size();
|
||||
idx = 0;
|
||||
i18n_log("Translations file size: " << datalen);
|
||||
|
||||
/* Format of the QM file (AFAICT):
|
||||
* 16 bytes magic
|
||||
* chunk list: N instances of chunks:
|
||||
* 1 byte: chunk type (0x42: offsets, 0x69: messages)
|
||||
* 4 bytes: chunk length, big endian
|
||||
* D bytes: "chunk length" bytes of data
|
||||
*
|
||||
* 0x42 chunk: N instances of subchunks:
|
||||
* 1 byte: subchunk type
|
||||
* 0x01: end, no data
|
||||
* 0x02: unsupported
|
||||
* 0x03: translation
|
||||
* 4 bytes: string length, big endian
|
||||
* N bytes: string data, UTF-16 (or UCS2-BE ?)
|
||||
* 0x04: unsupported
|
||||
* 0x05: obsolete, unsupported
|
||||
* 0x06: source text
|
||||
* 0x07: context
|
||||
* 0x08: obsolete, unsupported
|
||||
* other: unsupported
|
||||
* 4 bytes: subchunk length, big endian - except for 0x01, which has none
|
||||
* S bytes: "chunk length" bytes of data
|
||||
* 0x69 chunk:
|
||||
* string data indexed by the 0x42 chunk data
|
||||
*/
|
||||
if (datalen < sizeof(qm_magic) || memcmp(data, qm_magic, sizeof(qm_magic))) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
idx += sizeof(qm_magic);
|
||||
|
||||
while (idx < datalen) {
|
||||
if (idx + 5 > datalen) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
chunk_type = data[idx++];
|
||||
chunk_size = be32(data+idx);
|
||||
idx += 4;
|
||||
|
||||
i18n_log("Found " << chunk_type << " of " << chunk_size << " bytes");
|
||||
if (chunk_size >= datalen || idx > datalen - chunk_size) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (chunk_type) {
|
||||
case 0x42:
|
||||
i18n_log("Found offsets at " << idx);
|
||||
/* two 32 bit integers, and possible padding */
|
||||
offsets_idx = idx;
|
||||
num_messages = chunk_size / 8;
|
||||
break;
|
||||
case 0x69:
|
||||
i18n_log("Found messages at " << idx);
|
||||
messages_idx = idx;
|
||||
break;
|
||||
default:
|
||||
i18n_log("Found unsupported chunk type: " << chunk_type);
|
||||
break;
|
||||
}
|
||||
|
||||
idx += chunk_size;
|
||||
}
|
||||
|
||||
if (offsets_idx == (uint32_t)-1) {
|
||||
i18n_log("No offsets chunk found");
|
||||
return -1;
|
||||
}
|
||||
if (messages_idx == (uint32_t)-1) {
|
||||
i18n_log("No messages chunk found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (uint32_t m = 0; m < num_messages; ++m) {
|
||||
be32(data+offsets_idx+m*8); // unused
|
||||
idx = be32(data+offsets_idx+m*8+4);
|
||||
idx += messages_idx;
|
||||
|
||||
if (idx > datalen || idx + 1 > datalen) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (idx + 5 > datalen) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
chunk_type = data[idx++];
|
||||
chunk_size = 0;
|
||||
if (chunk_type == 0x01) {
|
||||
i18n_entries[context + std::string("",1) + source] = translation;
|
||||
context = std::string();
|
||||
source = std::string();
|
||||
translation = std::string();
|
||||
break;
|
||||
}
|
||||
|
||||
chunk_size = be32(data+idx);
|
||||
idx += 4;
|
||||
i18n_log("Found " << chunk_type << " of " << chunk_size << " bytes");
|
||||
if (chunk_size >= datalen || idx > datalen - chunk_size) {
|
||||
i18n_log("Bad translations file format: " << filename);
|
||||
return -1;
|
||||
}
|
||||
switch (chunk_type) {
|
||||
case 0x03: // translation, UTF-16
|
||||
translation = utf16(data+idx, chunk_size);
|
||||
i18n_log("Found translation: " << translation);
|
||||
break;
|
||||
case 0x06: // source, UTF-8
|
||||
source = utf8(data+idx, chunk_size);
|
||||
i18n_log("Found source: " << source);
|
||||
break;
|
||||
case 0x07: // context, UTF-8
|
||||
context = utf8(data+idx, chunk_size);
|
||||
i18n_log("Found context: " << context);
|
||||
break;
|
||||
}
|
||||
idx += chunk_size;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The entries is constant by that time */
|
||||
const char *i18n_translate(const char *s, const std::string &context)
|
||||
{
|
||||
const std::string key = context + std::string("", 1) + s;
|
||||
std::map<std::string,std::string>::const_iterator i = i18n_entries.find(key);
|
||||
if (i == i18n_entries.end())
|
||||
return s;
|
||||
return (*i).second.c_str();
|
||||
}
|
||||
|
||||
|
||||
+2
-9
@@ -28,12 +28,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#define QT_TRANSLATE_NOOP(context,str) i18n_translate(str,context)
|
||||
|
||||
std::string i18n_get_language();
|
||||
int i18n_set_language(const char *directory, const char *base, std::string language = std::string());
|
||||
const char *i18n_translate(const char *str, const std::string &context);
|
||||
static inline std::string get_default_i18n_context() { return std::string(); }
|
||||
static inline const char *tr(const char *str) { return i18n_translate(str,get_default_i18n_context()); }
|
||||
inline const char *i18n_translate(const char *str, const std::string &context) { return str; };
|
||||
static inline const char *tr(const char *str) { return str; }
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace cryptonote
|
||||
|
||||
if (std::chrono::milliseconds(20) < current_time - m_print_time || force)
|
||||
{
|
||||
std::cout << QT_TRANSLATE_NOOP("cryptonote::simple_wallet", "Height ") << height << " / " << m_blockchain_height << '\r' << std::flush;
|
||||
std::cout << "Height " << height << " / " << m_blockchain_height << '\r' << std::flush;
|
||||
m_print_time = current_time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,6 @@ namespace wallet_args
|
||||
const command_line::arg_descriptor<std::string> arg_config_file = {"config-file", wallet_args::tr("Config file"), "", true};
|
||||
|
||||
|
||||
std::string lang = i18n_get_language();
|
||||
tools::on_startup();
|
||||
#ifdef NDEBUG
|
||||
tools::disable_core_dumps();
|
||||
@@ -132,8 +131,6 @@ namespace wallet_args
|
||||
command_line::add_arg(desc_params, arg_max_concurrency);
|
||||
command_line::add_arg(desc_params, arg_config_file);
|
||||
|
||||
i18n_set_language("translations", "monero", lang);
|
||||
|
||||
po::options_description desc_all;
|
||||
desc_all.add(desc_general).add(desc_params);
|
||||
po::variables_map vm;
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
# Copyright (c) 2017-2024, The Monero Project
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other
|
||||
# materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(translations)
|
||||
|
||||
# when crosscompiling import the executable targets from a file
|
||||
IF(CMAKE_CROSSCOMPILING)
|
||||
message(WARNING "CrossCompiling")
|
||||
SET(IMPORT_EXECUTABLES "${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Point it to the export file from a native build")
|
||||
INCLUDE(${IMPORT_EXECUTABLES})
|
||||
ENDIF(CMAKE_CROSSCOMPILING)
|
||||
|
||||
# only build the generator if not crosscompiling
|
||||
IF(NOT CMAKE_CROSSCOMPILING)
|
||||
add_executable(generate_translations_header generate_translations_header.c)
|
||||
ENDIF(NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
if(LRELEASE_PATH STREQUAL "")
|
||||
find_program(LRELEASE lrelease)
|
||||
else()
|
||||
set(LRELEASE ${LRELEASE_PATH}/lrelease)
|
||||
endif()
|
||||
|
||||
if(LRELEASE STREQUAL "LRELEASE-NOTFOUND")
|
||||
set(ts_files "")
|
||||
message(WARNING "lrelease program not found, translation files not built")
|
||||
else()
|
||||
execute_process(COMMAND ${LRELEASE} -version
|
||||
RESULT_VARIABLE lrelease_ret)
|
||||
if(NOT lrelease_ret EQUAL "0")
|
||||
set(ts_files "")
|
||||
message(WARNING "lrelease program not working, translation files not built")
|
||||
else()
|
||||
file(GLOB ts_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.ts)
|
||||
foreach(ts_file ${ts_files})
|
||||
string(REPLACE ".ts" ".qm" qm_file "${ts_file}")
|
||||
add_custom_command(TARGET generate_translations_header
|
||||
PRE_BUILD
|
||||
COMMAND ${LRELEASE} "${CMAKE_CURRENT_SOURCE_DIR}/${ts_file}" -qm "${qm_file}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BIN_DIR}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REPLACE ".ts" ".qm" qm_files "${ts_files}")
|
||||
|
||||
add_custom_command(TARGET generate_translations_header
|
||||
POST_BUILD
|
||||
COMMAND $<TARGET_FILE:generate_translations_header> ${qm_files}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BIN_DIR}"
|
||||
COMMENT "Generating embedded translations header")
|
||||
|
||||
# export the generator target to a file, so it can be imported (see above) by another build
|
||||
IF(NOT CMAKE_CROSSCOMPILING)
|
||||
EXPORT(TARGETS generate_translations_header FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake )
|
||||
ENDIF(NOT CMAKE_CROSSCOMPILING)
|
||||
@@ -1,87 +0,0 @@
|
||||
// Copyright (c) 2013, Sergey Lyubka
|
||||
// Copyright (c) 2017-2024, The Monero Project
|
||||
// All rights reserved.
|
||||
// Released under the MIT license.
|
||||
|
||||
// This program takes a list of files as an input, and produces C++ code that
|
||||
// contains the contents of all these files as a collection of strings.
|
||||
//
|
||||
// Usage:
|
||||
// 1. Compile this file:
|
||||
// cc -o generate-translations-header generate-translations-header.c
|
||||
//
|
||||
// 2. Convert list of files into single header:
|
||||
// ./generate-translations-header monero_fr.qm monero_it.qm > translations_files.h
|
||||
//
|
||||
// 3. In your application code, include translations_files.h, then you can
|
||||
// access the files using this function:
|
||||
// static bool find_embedded_file(const std::string &file_name, std::string &data);
|
||||
// std::string data;
|
||||
// find_embedded_file("monero_fr.qm", data);
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char *code =
|
||||
"static bool find_embedded_file(const std::string &name, std::string &data) {\n"
|
||||
" const struct embedded_file *p;\n"
|
||||
" for (p = embedded_files; p->name != NULL; p++) {\n"
|
||||
" if (*p->name == name) {\n"
|
||||
" data = *p->data;\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
"}\n";
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
FILE *fp, *foutput;
|
||||
int i, j, ch;
|
||||
|
||||
if((foutput = fopen("translation_files.h", "w")) == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(foutput, "#ifndef TRANSLATION_FILES_H\n");
|
||||
fprintf(foutput, "#define TRANSLATION_FILES_H\n\n");
|
||||
fprintf(foutput, "#include <string>\n\n");
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if ((fp = fopen(argv[i], "rb")) == NULL) {
|
||||
fclose(foutput);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
fprintf(foutput, "static const std::string translation_file_name_%d = \"%s\";\n", i, argv[i]);
|
||||
fprintf(foutput, "static const std::string translation_file_data_%d = std::string(", i);
|
||||
for (j = 0; (ch = fgetc(fp)) != EOF; j++) {
|
||||
if ((j % 16) == 0) {
|
||||
if (j > 0) {
|
||||
fprintf(foutput, "%s", "\"");
|
||||
}
|
||||
fprintf(foutput, "%s", "\n \"");
|
||||
}
|
||||
fprintf(foutput, "\\x%02x", ch);
|
||||
}
|
||||
fprintf(foutput, "\",\n %d);\n\n", j);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(foutput, "%s", "static const struct embedded_file {\n");
|
||||
fprintf(foutput, "%s", " const std::string *name;\n");
|
||||
fprintf(foutput, "%s", " const std::string *data;\n");
|
||||
fprintf(foutput, "%s", "} embedded_files[] = {\n");
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
fprintf(foutput, " {&translation_file_name_%d, &translation_file_data_%d},\n", i, i);
|
||||
}
|
||||
fprintf(foutput, "%s", " {NULL, NULL}\n");
|
||||
fprintf(foutput, "%s", "};\n\n");
|
||||
fprintf(foutput, "%s\n", code);
|
||||
|
||||
fprintf(foutput, "#endif /* TRANSLATION_FILES_H */\n");
|
||||
|
||||
fclose(foutput);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
||||
fr
|
||||
it
|
||||
ja
|
||||
sv
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
lrelease=`which lrelease 2> /dev/null`
|
||||
if test -z "$lrelease"
|
||||
then
|
||||
lrelease=`which lrelease-qt4 2> /dev/null`
|
||||
fi
|
||||
if test -z "$lrelease"
|
||||
then
|
||||
lrelease=`which lrelease-qt5 2> /dev/null`
|
||||
fi
|
||||
if test -z "$lrelease"
|
||||
then
|
||||
echo "lrelease not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "using $lrelease"
|
||||
if test -f translations/ready
|
||||
then
|
||||
languages=""
|
||||
for language in $(cat translations/ready)
|
||||
do
|
||||
languages="$languages translations/monero_$language.ts"
|
||||
done
|
||||
else
|
||||
languages="translations/*.ts"
|
||||
fi
|
||||
"$lrelease" $languages
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
lupdate=`which lupdate 2> /dev/null`
|
||||
if test -z "$lupdate"
|
||||
then
|
||||
lupdate=`which lupdate-qt4 2> /dev/null`
|
||||
fi
|
||||
if test -z "$lupdate"
|
||||
then
|
||||
echo "lupdate not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "using $lupdate"
|
||||
"$lupdate" `find src -name \*.cpp` -ts translations/*.ts -no-obsolete -locations none
|
||||
|
||||
Reference in New Issue
Block a user