mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeee360fb0 | ||
|
|
f69973e1fa | ||
|
|
931fc98478 | ||
|
|
6f30be7815 | ||
|
|
1a926d1b69 | ||
|
|
e89cfa18b1 | ||
|
|
12d9ea5b97 | ||
|
|
920c2bafb9 | ||
|
|
5d2332b0cb | ||
|
|
452a4e07fb | ||
|
|
59ef936288 | ||
|
|
d054adb37c | ||
|
|
4a9b1dae3d | ||
|
|
6d385221d0 | ||
|
|
3d15ce3b07 | ||
|
|
51338ac5bb | ||
|
|
5ada75e08d | ||
|
|
c7d9944f7d | ||
|
|
3963e358cd | ||
|
|
3b26731b02 | ||
|
|
070a9fb0bd | ||
|
|
8f096629ec | ||
|
|
25768c6b80 | ||
|
|
4ae4207349 | ||
|
|
994c1c7ae6 | ||
|
|
d38f8f13c9 | ||
|
|
cc7bcb8b73 | ||
|
|
8e9f72ae57 | ||
|
|
88af1a077c | ||
|
|
b66799f358 | ||
|
|
be5c3a35bf | ||
|
|
e73388c726 | ||
|
|
7e8fee5e78 | ||
|
|
bc890621a9 | ||
|
|
0836551bb4 | ||
|
|
824764ab50 | ||
|
|
431a5774ba | ||
|
|
7facbe215e | ||
|
|
79773d6af9 | ||
|
|
373bd786d7 | ||
|
|
cef6eb5447 | ||
|
|
995bdc5bdb | ||
|
|
581c2d2b5c | ||
|
|
958ec353ca | ||
|
|
2fd47ba0d0 | ||
|
|
357ca4d453 | ||
|
|
3736ef0060 | ||
|
|
3413d847c5 | ||
|
|
780b7dd214 | ||
|
|
08461acab8 | ||
|
|
2d1a454026 | ||
|
|
021e467b37 | ||
|
|
a500176661 | ||
|
|
7341675088 | ||
|
|
51f808d96c | ||
|
|
7719111c57 | ||
|
|
51db56f7e5 | ||
|
|
0f83f0aa0b | ||
|
|
a7432338ee | ||
|
|
69fe19d269 | ||
|
|
b9a1fba5bb | ||
|
|
ac2acfdcd2 | ||
|
|
925a4bc163 | ||
|
|
4b6486c58e |
@@ -15,7 +15,7 @@ BreakBeforeBinaryOperators: true
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BinPackParameters: true
|
||||
ColumnLimit: 0
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
DerivePointerAlignment: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
|
||||
48
.github/workflows/main.yml
vendored
Normal file
48
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
- cron: '00 02 */4 * *'
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
jobs:
|
||||
tests:
|
||||
name: Run tests
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- uses: jwlawson/actions-setup-cmake@v1.4
|
||||
with:
|
||||
cmake-version: '3.5.1'
|
||||
github-api-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Check versions
|
||||
run: |
|
||||
set -e
|
||||
cmake --version
|
||||
gcc --version
|
||||
echo "end of versions checking"
|
||||
shell: bash
|
||||
- name: Run tests
|
||||
run: |
|
||||
set -e
|
||||
cd $GITHUB_WORKSPACE
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_TESTS=True ..
|
||||
make -k -j2 VERBOSE=1
|
||||
ctest --output-on-failure
|
||||
shell: bash
|
||||
49
.travis.yml
49
.travis.yml
@@ -1,49 +0,0 @@
|
||||
#
|
||||
# Available repositories are listed here:
|
||||
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
|
||||
#
|
||||
|
||||
sudo: false
|
||||
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- env: COMPILER_VERSION=4.8
|
||||
os: linux
|
||||
compiler: g++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- kalakris-cmake
|
||||
- ubuntu-sdk-team
|
||||
packages:
|
||||
- g++-4.8
|
||||
- cmake
|
||||
- libglib2.0-dev
|
||||
- jq
|
||||
# - env: COMPILER_VERSION=3.5
|
||||
# os: linux
|
||||
# compiler: clang++
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
# - llvm-toolchain-precise-3.5
|
||||
# packages:
|
||||
# - clang-3.5
|
||||
# - cmake
|
||||
# - libglib2.0-dev
|
||||
|
||||
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- CC=$CC-${COMPILER_VERSION} CXX=$CXX-${COMPILER_VERSION} cmake -DBUILD_TESTS=True ..
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
- cd build
|
||||
- make -k -j2 VERBOSE=1
|
||||
- ctest --output-on-failure
|
||||
@@ -1,24 +1,18 @@
|
||||
project(sdcv)
|
||||
|
||||
# Older versions have a different signature for CMAKE_MINIMUM_REQUIRED,
|
||||
# check it manually just to make sure
|
||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
|
||||
message(FATAL_ERROR "${PROJECT_NAME} requires at least CMake v2.8."
|
||||
" You are running v${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}."
|
||||
" Please upgrade." )
|
||||
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
cmake_policy(VERSION 3.5)
|
||||
|
||||
# If we get this far, use the modern signature. This will also cause newer
|
||||
# CMake versions to try to be backwards-compatible with the desired version
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
cmake_policy(VERSION 2.8)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_CXX_EXTENSIONS False)
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler.cmake")
|
||||
|
||||
set(ZLIB_FIND_REQUIRED True)
|
||||
include(FindZLIB)
|
||||
|
||||
set(GLIB2_REQ "'glib-2.0 >= 2.6.1'")
|
||||
set(GLIB2_REQ "'glib-2.0 >= 2.36'")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGLIB2.cmake")
|
||||
|
||||
@@ -101,7 +95,7 @@ set(CPACK_PACKAGE_VENDOR "Evgeniy Dushistov <dushistov@mail.ru>")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.org")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "5")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "2")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "4")
|
||||
|
||||
set(sdcv_VERSION
|
||||
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
@@ -152,5 +146,8 @@ if (BUILD_TESTS)
|
||||
add_sdcv_shell_test(t_utf8output)
|
||||
add_sdcv_shell_test(t_utf8input)
|
||||
add_sdcv_shell_test(t_datadir)
|
||||
add_sdcv_shell_test(t_return_code)
|
||||
add_sdcv_shell_test(t_multiple_results)
|
||||
add_sdcv_shell_test(t_newlines_in_ifo)
|
||||
|
||||
endif (BUILD_TESTS)
|
||||
|
||||
16
NEWS
16
NEWS
@@ -1,9 +1,15 @@
|
||||
Version 0.5.3
|
||||
- Use single quotes around JSON data to reduce need for escaping
|
||||
- Store integer magic in cache file
|
||||
- Added $SDCV_HISTFILE to set history file
|
||||
- return exit code 2 if search term not found
|
||||
- Comply with the XDG Base Directory Specification
|
||||
Version 0.5.2
|
||||
Synonyms index support (.syn files) by Peter <craven@gmx.net>
|
||||
Add support of json output by Peter <craven@gmx.net> (--json-output)
|
||||
Add -e for exact searches (no fuzzy matches) by Peter <craven@gmx.net>
|
||||
Fix build with clang 3.4.1
|
||||
fix FSF address in license by Tomáš Čech <sleep_walker@suse.com>
|
||||
- Synonyms index support (.syn files) by Peter <craven@gmx.net>
|
||||
- Add support of json output by Peter <craven@gmx.net> (--json-output)
|
||||
- Add -e for exact searches (no fuzzy matches) by Peter <craven@gmx.net>
|
||||
- Fix build with clang 3.4.1
|
||||
- fix FSF address in license by Tomáš Čech <sleep_walker@suse.com>
|
||||
|
||||
Version 0.5.1
|
||||
Fix usage of SDCV_PAGER by Anton Yuzhaninov
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+OPTIONS: ^:nil
|
||||
[[https://travis-ci.org/Dushistov/sdcv][https://travis-ci.org/Dushistov/sdcv.svg?branch=master]]
|
||||
[[https://github.com/Dushistov/sdcv/actions?query=workflow%3ACI+branch%3Amaster][https://github.com/Dushistov/sdcv/workflows/CI/badge.svg]]
|
||||
[[https://github.com/Dushistov/sdcv/blob/master/LICENSE][https://img.shields.io/badge/license-GPL%202-brightgreen.svg]]
|
||||
* How to compile and install
|
||||
#+BEGIN_SRC sh
|
||||
@@ -22,7 +22,8 @@ you can use "DESTDIR" variable to change installation path
|
||||
See sdcv man page for usage description.
|
||||
|
||||
* Bugs
|
||||
If you find bug reports it via email to dushistov at mail dot ru.
|
||||
To report bugs use https://github.com/Dushistov/sdcv/issues ,
|
||||
if it is not possible you can report it via email to dushistov at mail dot ru.
|
||||
Be sure to include the word "sdcv" somewhere in the "Subject:" field.
|
||||
|
||||
* Notes to developer
|
||||
|
||||
@@ -16,19 +16,6 @@ if (NOT DEFINED SDCV_COMPILER_IS_GCC_COMPATIBLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MSVC AND (MSVC_VERSION LESS 1900))
|
||||
message(FATAL_ERROR "MSVC version ${MSVC_VERSION} have no full c++11 support")
|
||||
elseif (MSVC)
|
||||
add_definitions(-DNOMINMAX)
|
||||
elseif (NOT MSVC)
|
||||
check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
|
||||
if (CXX_SUPPORTS_CXX11)
|
||||
append("-std=c++11" CMAKE_CXX_FLAGS)
|
||||
else ()
|
||||
message(FATAL_ERROR "sdcv requires C++11 support but the '-std=c++11' flag isn't supported.")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (SDCV_COMPILER_IS_GCC_COMPATIBLE)
|
||||
append("-Wall" "-Wextra" "-Wformat-security" "-Wcast-align" "-Werror=format" "-Wcast-qual" CMAKE_C_FLAGS)
|
||||
append("-Wall" "-pedantic" "-Wextra" "-Wformat-security" "-Wcast-align" "-Werror=format" "-Wcast-qual" CMAKE_CXX_FLAGS)
|
||||
|
||||
17
doc/sdcv.1
17
doc/sdcv.1
@@ -25,7 +25,7 @@ you can use the UP and DOWN keys to cycle through history.
|
||||
.B "\-h \-\-help"
|
||||
Display help message and exit
|
||||
.TP 8
|
||||
.B "\-v \-\-verbose"
|
||||
.B "\-v \-\-version"
|
||||
Display version and exit
|
||||
.TP 8
|
||||
.B "\-l \-\-list\-dicts"
|
||||
@@ -64,7 +64,7 @@ Use ANSI escape codes for colorizing sdcv output (does not work with json output
|
||||
.TP
|
||||
/usr/share/stardict/dic
|
||||
.TP
|
||||
$(HOME)/.stardict/dic
|
||||
$(XDG_DATA_HOME)/stardict/dic
|
||||
|
||||
Place where sdcv expects to find dictionaries.
|
||||
Instead of /usr/share/stardict/dic you can use any directory
|
||||
@@ -72,12 +72,12 @@ you want, just set the STARDICT_DATA_DIR environment variable.
|
||||
For example, if you have dictionaries in /mnt/data/stardict-dicts/dic,
|
||||
set STARDICT_DATA_DIR to /mnt/data/stardict-dicts.
|
||||
.TP
|
||||
$(HOME)/.sdcv_history
|
||||
$(XDG_DATA_HOME)/sdcv_history
|
||||
|
||||
This file includes the last $(SDCV_HISTSIZE) words, which you sought with sdcv.
|
||||
SDCV uses this file only if it was compiled with readline library support.
|
||||
.TP
|
||||
$(HOME)/.sdcv_ordering
|
||||
$(XDG_CONFIG_HOME)/sdcv_ordering
|
||||
|
||||
This is a text file containing one dictionary bookname per line.
|
||||
It specifies in which order the results of a search should be shown.
|
||||
@@ -86,11 +86,14 @@ Environment Variables Used By \fIsdcv\fR:
|
||||
.TP 20
|
||||
.B STARDICT_DATA_DIR
|
||||
If set, sdcv uses this variable as the data directory, this means that sdcv
|
||||
searches dictionaries in $\fBSTARDICT_DATA_DIR\fR\\dic
|
||||
searches dictionaries in $\fBSTARDICT_DATA_DIR\fR/dic
|
||||
.TP 20
|
||||
.B SDCV_HISTSIZE
|
||||
If set, sdcv writes in $(HOME)/.sdcv_history the last $(SDCV_HISTSIZE) words,
|
||||
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(HOME)/.sdcv_history.
|
||||
If set, sdcv writes in $(XDG_DATA_HOME)/sdcv_history (or $(SDCV_HISTFILE)) the last $(SDCV_HISTSIZE) words,
|
||||
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(XDG_DATA_HOME)/sdcv_history.
|
||||
.TP 20
|
||||
.B SDCV_HISTFILE
|
||||
If set, sdcv writes it's history to $(SDCV_HISTFILE). If it is not set, then the default $(XDG_DATA_HOME)/sdcv_history path will be used.
|
||||
.TP 20
|
||||
.B SDCV_PAGER
|
||||
If SDCV_PAGER is set, its value is used as the name of the program
|
||||
|
||||
@@ -50,7 +50,7 @@ sdcv проста, міжплатформена текстова утиліта
|
||||
.TP
|
||||
/usr/share/stardict/dic
|
||||
.TP
|
||||
$(HOME)/.stardict/dic
|
||||
$(XDG_DATA_HOME)/stardict/dic
|
||||
|
||||
Місце, де sdcv очікує знайти словники.
|
||||
Замість шляху /usr/share/stardict/dic Ви можете використовувати все,
|
||||
@@ -58,7 +58,7 @@ $(HOME)/.stardict/dic
|
||||
Наприклад, якщо Ви маєте словники у теці /mnt/data/stardict-dicts/dic,
|
||||
встановіть STARDICT_DATA_DIR у /mnt/data/stardict-dicts.
|
||||
.TP
|
||||
$(HOME)/.sdcv_history
|
||||
$(XDG_DATA_HOME)/sdcv_history
|
||||
|
||||
Цей файл містить останні $(SDCV_HISTSIZE) слова, які Ви шукали з sdcv.
|
||||
SDCV використовує цей файл при умові, якщо sdcv був скомпільований
|
||||
@@ -69,12 +69,12 @@ SDCV використовує цей файл при умові, якщо sdcv
|
||||
.TP 20
|
||||
.B STARDICT_DATA_DIR
|
||||
Якщо встановлена, sdcv використає цю змінну як теку даних, це означає,
|
||||
що sdcv шукатиме словники у $\fBSTARDICT_DATA_DIR\fR\dic
|
||||
що sdcv шукатиме словники у $\fBSTARDICT_DATA_DIR\fR/dic
|
||||
.TP 20
|
||||
.B SDCV_HISTSIZE
|
||||
Якщо встановлена, sdcv писатиме у $(HOME)/.sdcv_history лише
|
||||
Якщо встановлена, sdcv писатиме у $(XDG_DATA_HOME)/sdcv_history лише
|
||||
останні $(SDCV_HISTSIZE) слова, які Ви шукали з sdcv. Якщо не встановлена,
|
||||
то збірігатиметься останніх 2000 слів у $(HOME)/.sdcv_history.
|
||||
то збірігатиметься останніх 2000 слів у $(XDG_DATA_HOME)/sdcv_history.
|
||||
.SH BUGS
|
||||
Звіти про помилки висилайте на адресу dushistov на mail крапка ru.
|
||||
Не забувайте включати слово "sdcv" десь у полі "Тема:".
|
||||
|
||||
52
po/cs.po
52
po/cs.po
@@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.4.2\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2008-09-24 10:42+0200\n"
|
||||
"Last-Translator: Michal Čihař <michal@cihar.com>\n"
|
||||
"Language-Team: Czech <cs@li.org>\n"
|
||||
@@ -20,21 +20,21 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr "popen selhalo"
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "Nepodařilo se převést %s do utf8.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "Nalezeno %d záznamů podobných %s.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "Vaše volba [-1 pro ukončení]: "
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -43,102 +43,102 @@ msgstr ""
|
||||
"Chybná volba.\n"
|
||||
"Musí být mezi 0 a %d nebo -1.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "Nic podobného %s nenalezeno, promiň :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr "-v, --version zobrazí informace o verzi a skončí\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr "-l, --list-dicts zobrazí seznam dostupných slovníků a skončí\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr "-u, --use-dict jméno vyhledávat jen v zadaném slovníku\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output výstup musí být v utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input vstup musí být v utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
"--data-dir cesta/někam použít tento adresář jako cestu ke slovníkům "
|
||||
"stardict\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Konzolová verze Stardictu, verze %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr "g_mkdir selhalo: %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "Zadejte slovo nebo frázi: "
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "Nebyla zadáno nic k přeložení.\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "Jméno slovníku Počet slov\n"
|
||||
|
||||
52
po/fr.po
52
po/fr.po
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.4.2\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2009-06-15 23:20+0800\n"
|
||||
"Language-Team: Vincent Petry <PVince81@yahoo.fr>\n"
|
||||
"Language: \n"
|
||||
@@ -22,21 +22,21 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr "Échec de popen"
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "Ne peut convertir %s au format utf8.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "Trouvé %d éléments similaires à %s.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "Votre choix[-1 pour abandonner] : "
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -45,107 +45,107 @@ msgstr ""
|
||||
"Selection invalide.\n"
|
||||
"Veuillez choisir un nombre entre 0 et %d, ou -1.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "Aucun mot/phrase similaire à %s, désolé :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr ""
|
||||
"-v, --version afficher les informations de version et sortir\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr ""
|
||||
"-l, --list-dicts afficher la liste des dictionnaires disponibles et "
|
||||
"sortir\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr ""
|
||||
"-u, --use-dict nom_dict pour chercher seulement en utilisant le "
|
||||
"dictionnaire spécifié\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output force la sortie au format utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input force l'entrée de sdcv au format utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
"--data-dir chemin utiliser ce chemin pour trouver les données de "
|
||||
"stardict\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Version console de Stardict, version %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr "Échec de g_mkdir : %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "Entrez un mot ou une phrase: "
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "Il n'y a pas de mots/phrases à traduire.\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "Nom dictionnaire Nombre de mots\n"
|
||||
|
||||
59
po/ru.po
59
po/ru.po
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.5\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2017-08-16 10:05+0300\n"
|
||||
"Last-Translator: Evgeniy Dushistov <dushistov@mail.ru>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
@@ -23,21 +23,21 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr "функция popen завершилась с ошибкой"
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "Не могу преобразовать %s в utf8.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "Найдено %zu слов, похожих на %s.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "Ваш выбор[-1 - отмена]: "
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -46,95 +46,98 @@ msgstr ""
|
||||
"Неправильный выбор.\n"
|
||||
"Должно быть от 0 до %zu или -1.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "Ничего похожего на %s, извините :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
msgid "display version information and exit"
|
||||
msgstr "показать номер версии и завершить работу"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr "показать список доступных словарей и завершить работу"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr "для поиска использовать только этот словарь с таким именем"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr "имя_словаря"
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr "для использования в скриптах"
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr "выдать результат в JSON формате"
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr "не использовать нечеткий поиск похожих слов, вернуть только точные совпадения"
|
||||
msgstr ""
|
||||
"не использовать нечеткий поиск похожих слов, вернуть только точные совпадения"
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
msgid "output must be in utf8"
|
||||
msgstr "вывод программы должен быть в utf8"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "ввод программы в utf8"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
"использовать эту директорию в качестве пути к \"stardict data\" директории"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr "путь/до/директории"
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr "использовать словари только из data-dir, не искать в пользовательских и системных каталогах"
|
||||
msgstr ""
|
||||
"использовать словари только из data-dir, не искать в пользовательских и "
|
||||
"системных каталогах"
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr "раскрашивать вывод в разные цвета"
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr "слова"
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr "Неправильный аргумент командой строки: %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Консольная версия StarDict, версия %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr "g_mkdir завершился с ошибкой: %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "Введите слово или фразу: "
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "Не задано слова/фразы для перевода.\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "Название словаря Количество слов\n"
|
||||
|
||||
52
po/sdcv.pot
52
po/sdcv.pot
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.5\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2017-08-16 10:01+0300\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -20,115 +20,115 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
"It must be from 0 to %zu or -1.\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
msgid "display version information and exit"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
msgid "output must be in utf8"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr ""
|
||||
|
||||
52
po/sk.po
52
po/sk.po
@@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.3.2\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2007-09-11 00:22+0100\n"
|
||||
"Last-Translator: Ivan Masár <helix84@centrum.sk>\n"
|
||||
"Language-Team: Slovak <sk-i18n@lists.linux.sk>\n"
|
||||
@@ -22,22 +22,22 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr "popen zlyhalo"
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "nie je možné konvertovať %s na utf8.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "Nájdené %d položiek, podobných %s,\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
#, fuzzy
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "Vaša voľba[-1 zruší]: "
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -46,103 +46,103 @@ msgstr ""
|
||||
"Neplatná voľba.\n"
|
||||
"Musí byť od 0 do %d alebo -1.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "Ľutujem, nič sa nepodobá na %s :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr "-v, --version zobrazí informácie o verzii a skončí\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr ""
|
||||
"-l, --list-dicts zobrazí zoznam dostupných slovníkov a skončí\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr "-u, --use-dict názov použiť pre hľadanie iba zvolený slovník\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output výstup musí byť v utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input vstup pre sdcv je v utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
"--data-dir path/to/dir použiť tento priečinok ako cestu pre stardict "
|
||||
"dátový priečinok\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Konzolová verzia StarDict, verzia %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr "g_mkdir zlyhalo: %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "Vložte slovo alebo frázu: "
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "Nie je čo preložiť.\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "názov slovníka počet slov\n"
|
||||
|
||||
52
po/uk.po
52
po/uk.po
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.3\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2004-12-14 17:54+0300\n"
|
||||
"Last-Translator: <dubyk@lsl.lviv.ua>\n"
|
||||
"Language-Team: Ukrainian <dubyk@lsl.lviv.ua>\n"
|
||||
@@ -23,22 +23,22 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "Не можу перетворити %s у utf8.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "Знайдено %d слів, схожих на %s.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
#, fuzzy
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "Ваш вибір: "
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -47,105 +47,105 @@ msgstr ""
|
||||
"Неправильний вибір.\n"
|
||||
"Повинно бути від 0 до %d.\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "Нічого схожого на %s, даруйте :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr "-v, --version показати номер версії і завершити роботу\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr ""
|
||||
"-l, --list-dicts показати список доступних словників і завершити "
|
||||
"роботу\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr ""
|
||||
"-u, --use-dict ім`я словника для пошуку використовувати лише цей словник\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output вивід програми повинен бути в utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input ввід програми в utf8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr ""
|
||||
"--data-dir тека використовувати цю теку як шлях до stardict data "
|
||||
"directory\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Консольна версія Зоряного словника [Stardict], номер версії %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "ВведЁть слово або фразу: "
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "Не задано слова/фрази для перекладу.\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, fuzzy, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "назва словника кількість слів\n"
|
||||
|
||||
52
po/zh_CN.po
52
po/zh_CN.po
@@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.3\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2005-1-17 00:58+0800\n"
|
||||
"Last-Translator: Cai Qian <caiqian@gnome.org>\n"
|
||||
"Language-Team: Simplified Chinese\n"
|
||||
@@ -19,22 +19,22 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "无法将 %s 转换为 UTF-8。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "发现 %d 条记录和 %s 相似。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
#, fuzzy
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "您的选择为:"
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -43,100 +43,100 @@ msgstr ""
|
||||
"无效的选择。\n"
|
||||
"必须是 0 到 %d。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "对不起,没有发现和 %s 相似的 :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr "-v, --version 显示版本信息并退出\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr "-l, --list-dicts 显示可用的字典列表并退出\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr "-u, --use-dict 字典名 只使用指定的字典进行单词搜索\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output 输出必须是 UTF-8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input sdcv 的输入为 UTF-8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr "--data-dir 目录路径 指定 Stardict 数据所在目录的路径\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Stardict 的控制台版本,版本为 %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "请输入单词或短语:"
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "没有供翻译的单词或短语。\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, fuzzy, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "字典名 单词量\n"
|
||||
|
||||
52
po/zh_TW.po
52
po/zh_TW.po
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sdcv 0.4.2\n"
|
||||
"Report-Msgid-Bugs-To: dushistov@mail.ru\n"
|
||||
"POT-Creation-Date: 2017-08-16 09:52+0300\n"
|
||||
"POT-Creation-Date: 2020-08-14 12:58+0300\n"
|
||||
"PO-Revision-Date: 2013-06-12 14:11+0800\n"
|
||||
"Last-Translator: Wei-Lun Chao <bluebat@member.fsf.org>\n"
|
||||
"Language-Team: Chinese (traditional) <zh-l10n@linux.org.tw>\n"
|
||||
@@ -22,21 +22,21 @@ msgstr ""
|
||||
msgid "popen failed"
|
||||
msgstr "popen 失敗"
|
||||
|
||||
#: ../src/libwrapper.cpp:340
|
||||
#: ../src/libwrapper.cpp:341
|
||||
#, c-format
|
||||
msgid "Can not convert %s to utf8.\n"
|
||||
msgstr "無法將 %s 轉換為 UTF-8。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:398 ../src/libwrapper.cpp:432
|
||||
#: ../src/libwrapper.cpp:399 ../src/libwrapper.cpp:433
|
||||
#, fuzzy, c-format
|
||||
msgid "Found %zu items, similar to %s.\n"
|
||||
msgstr "找到 %d 項紀錄和 %s 相似。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:416
|
||||
#: ../src/libwrapper.cpp:417
|
||||
msgid "Your choice[-1 to abort]: "
|
||||
msgstr "您的選擇是[-1 表示放棄]:"
|
||||
|
||||
#: ../src/libwrapper.cpp:426
|
||||
#: ../src/libwrapper.cpp:427
|
||||
#, fuzzy, c-format
|
||||
msgid ""
|
||||
"Invalid choice.\n"
|
||||
@@ -45,100 +45,100 @@ msgstr ""
|
||||
"無效的選擇。\n"
|
||||
"必須是 0 到 %d 之間或 -1。\n"
|
||||
|
||||
#: ../src/libwrapper.cpp:445
|
||||
#: ../src/libwrapper.cpp:446
|
||||
#, c-format
|
||||
msgid "Nothing similar to %s, sorry :(\n"
|
||||
msgstr "抱歉,沒有和 %s 相似者 :(\n"
|
||||
|
||||
#: ../src/sdcv.cpp:88
|
||||
#: ../src/sdcv.cpp:89
|
||||
#, fuzzy
|
||||
msgid "display version information and exit"
|
||||
msgstr "-v, --version 顯示版本資訊並離開\n"
|
||||
|
||||
#: ../src/sdcv.cpp:90
|
||||
#: ../src/sdcv.cpp:91
|
||||
#, fuzzy
|
||||
msgid "display list of available dictionaries and exit"
|
||||
msgstr "-l, --list-dicts 顯示可用的字典清單並離開\n"
|
||||
|
||||
#: ../src/sdcv.cpp:92
|
||||
#: ../src/sdcv.cpp:93
|
||||
#, fuzzy
|
||||
msgid "for search use only dictionary with this bookname"
|
||||
msgstr "-u, --use-dict 字典名 只使用指定的字典進行單字搜尋\n"
|
||||
|
||||
#: ../src/sdcv.cpp:93
|
||||
#: ../src/sdcv.cpp:94
|
||||
msgid "bookname"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:95
|
||||
#: ../src/sdcv.cpp:96
|
||||
msgid "for use in scripts"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:97
|
||||
#: ../src/sdcv.cpp:98
|
||||
msgid "print the result formatted as JSON"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:99
|
||||
#: ../src/sdcv.cpp:100
|
||||
msgid "do not fuzzy-search for similar words, only return exact matches"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:101
|
||||
#: ../src/sdcv.cpp:102
|
||||
#, fuzzy
|
||||
msgid "output must be in utf8"
|
||||
msgstr "--utf8-output 輸出必須是 UTF-8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:103
|
||||
#: ../src/sdcv.cpp:104
|
||||
#, fuzzy
|
||||
msgid "input of sdcv in utf8"
|
||||
msgstr "--utf8-input sdcv 的輸入為 UTF-8\n"
|
||||
|
||||
#: ../src/sdcv.cpp:105
|
||||
#: ../src/sdcv.cpp:106
|
||||
#, fuzzy
|
||||
msgid "use this directory as path to stardict data directory"
|
||||
msgstr "--data-dir 目錄路徑 指定 Stardict 資料所在目錄的路徑\n"
|
||||
|
||||
#: ../src/sdcv.cpp:106
|
||||
#: ../src/sdcv.cpp:107
|
||||
msgid "path/to/dir"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:108
|
||||
#: ../src/sdcv.cpp:109
|
||||
msgid ""
|
||||
"only use the dictionaries in data-dir, do not search in user and system "
|
||||
"directories"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:110
|
||||
#: ../src/sdcv.cpp:111
|
||||
msgid "colorize the output"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:115
|
||||
#: ../src/sdcv.cpp:116
|
||||
msgid " words"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:121
|
||||
#: ../src/sdcv.cpp:122
|
||||
#, c-format
|
||||
msgid "Invalid command line arguments: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/sdcv.cpp:127
|
||||
#: ../src/sdcv.cpp:128
|
||||
#, c-format
|
||||
msgid "Console version of Stardict, version %s\n"
|
||||
msgstr "Stardict 的主控臺版本,版本為 %s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:202
|
||||
#: ../src/sdcv.cpp:206
|
||||
#, c-format
|
||||
msgid "g_mkdir failed: %s\n"
|
||||
msgstr "g_mkdir 失敗:%s\n"
|
||||
|
||||
#: ../src/sdcv.cpp:217
|
||||
#: ../src/sdcv.cpp:222
|
||||
msgid "Enter word or phrase: "
|
||||
msgstr "請輸入單字或片語:"
|
||||
|
||||
#: ../src/sdcv.cpp:225
|
||||
#: ../src/sdcv.cpp:230
|
||||
#, c-format
|
||||
msgid "There are no words/phrases to translate.\n"
|
||||
msgstr "沒有可供翻譯的單字或片語。\n"
|
||||
|
||||
#: ../src/sdcv.cpp:237
|
||||
#: ../src/sdcv.cpp:242
|
||||
#, c-format
|
||||
msgid "Dictionary's name Word count\n"
|
||||
msgstr "字典名稱 單字數量\n"
|
||||
|
||||
@@ -199,14 +199,18 @@ static std::string parse_data(const gchar *data, bool colorize_output)
|
||||
|
||||
void Library::SimpleLookup(const std::string &str, TSearchResultList &res_list)
|
||||
{
|
||||
glong ind;
|
||||
std::set<glong> wordIdxs;
|
||||
res_list.reserve(ndicts());
|
||||
for (gint idict = 0; idict < ndicts(); ++idict)
|
||||
if (SimpleLookupWord(str.c_str(), ind, idict))
|
||||
for (gint idict = 0; idict < ndicts(); ++idict) {
|
||||
wordIdxs.clear();
|
||||
if (SimpleLookupWord(str.c_str(), wordIdxs, idict))
|
||||
for (auto &wordIdx : wordIdxs)
|
||||
res_list.push_back(
|
||||
TSearchResult(dict_name(idict),
|
||||
poGetWord(ind, idict),
|
||||
parse_data(poGetWordData(ind, idict), colorize_output_)));
|
||||
poGetWord(wordIdx, idict),
|
||||
parse_data(poGetWordData(wordIdx, idict),
|
||||
colorize_output_)));
|
||||
}
|
||||
}
|
||||
|
||||
void Library::LookupWithFuzzy(const std::string &str, TSearchResultList &res_list)
|
||||
@@ -314,12 +318,12 @@ public:
|
||||
private:
|
||||
FILE *output;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||
search_result Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||
{
|
||||
if (nullptr == loc_str)
|
||||
return true;
|
||||
return SEARCH_SUCCESS;
|
||||
|
||||
std::string query;
|
||||
|
||||
@@ -330,6 +334,7 @@ bool Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||
gsize bytes_read;
|
||||
gsize bytes_written;
|
||||
glib::Error err;
|
||||
search_result rval = SEARCH_SUCCESS;
|
||||
glib::CharStr str;
|
||||
if (!utf8_input_)
|
||||
str.reset(g_locale_to_utf8(loc_str, -1, &bytes_read, &bytes_written, get_addr(err)));
|
||||
@@ -339,11 +344,11 @@ bool Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||
if (nullptr == get_impl(str)) {
|
||||
fprintf(stderr, _("Can not convert %s to utf8.\n"), loc_str);
|
||||
fprintf(stderr, "%s\n", err->message);
|
||||
return false;
|
||||
return SEARCH_FAILURE;
|
||||
}
|
||||
|
||||
if (str[0] == '\0')
|
||||
return true;
|
||||
return SEARCH_SUCCESS;
|
||||
|
||||
TSearchResultList res_list;
|
||||
|
||||
@@ -443,10 +448,11 @@ bool Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||
loc_str = utf8_to_locale_ign_err(get_impl(str));
|
||||
if (!json_)
|
||||
printf(_("Nothing similar to %s, sorry :(\n"), utf8_output_ ? get_impl(str) : loc_str.c_str());
|
||||
rval = SEARCH_NO_RESULT;
|
||||
}
|
||||
|
||||
if (json_) {
|
||||
fputs("]\n", stdout);
|
||||
}
|
||||
return true;
|
||||
return rval;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ struct TSearchResult {
|
||||
|
||||
typedef std::vector<TSearchResult> TSearchResultList;
|
||||
|
||||
//possible return values for Library.process_phase()
|
||||
enum search_result {
|
||||
SEARCH_SUCCESS = 0,
|
||||
SEARCH_FAILURE,
|
||||
SEARCH_NO_RESULT
|
||||
};
|
||||
|
||||
//this class is wrapper around Dicts class for easy use
|
||||
//of it
|
||||
class Library : public Libs
|
||||
@@ -38,7 +45,7 @@ public:
|
||||
setFuzzy(!no_fuzzy);
|
||||
}
|
||||
|
||||
bool process_phrase(const char *loc_str, IReadLine &io, bool force = false);
|
||||
search_result process_phrase(const char *loc_str, IReadLine &io, bool force = false);
|
||||
|
||||
private:
|
||||
bool utf8_input_;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#ifdef HAVE_MMAP
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
@@ -43,6 +44,13 @@ inline bool MapFile::open(const char *file_name, unsigned long file_size)
|
||||
// g_print("Open file %s failed!\n",fullfilename);
|
||||
return false;
|
||||
}
|
||||
struct stat st;
|
||||
if (fstat(mmap_fd, &st) == -1 || st.st_size < 0 || (st.st_size == 0 && S_ISREG(st.st_mode))
|
||||
|| sizeof(st.st_size) > sizeof(file_size) || static_cast<unsigned long>(st.st_size) != file_size) {
|
||||
close(mmap_fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
data = (gchar *)mmap(nullptr, file_size, PROT_READ, MAP_SHARED, mmap_fd, 0);
|
||||
if ((void *)data == (void *)(-1)) {
|
||||
// g_print("mmap file %s failed!\n",idxfilename);
|
||||
@@ -50,10 +58,8 @@ inline bool MapFile::open(const char *file_name, unsigned long file_size)
|
||||
return false;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
hFile = CreateFile(file_name, GENERIC_READ, 0, nullptr, OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READONLY, 0,
|
||||
file_size, nullptr);
|
||||
hFile = CreateFile(file_name, GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READONLY, 0, file_size, nullptr);
|
||||
data = (gchar *)MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, file_size);
|
||||
#else
|
||||
gsize read_len;
|
||||
|
||||
@@ -57,11 +57,25 @@ public:
|
||||
return stdio_getline(stdin, line);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
#else
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string get_hist_file_path()
|
||||
{
|
||||
const gchar *hist_file_str = g_getenv("SDCV_HISTFILE");
|
||||
|
||||
if (hist_file_str != nullptr)
|
||||
return std::string(hist_file_str);
|
||||
|
||||
const std::string hist_file_path = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||
if (g_file_test(hist_file_path.c_str(), G_FILE_TEST_IS_REGULAR))
|
||||
return hist_file_path;
|
||||
|
||||
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
||||
}
|
||||
|
||||
class real_readline : public IReadLine
|
||||
{
|
||||
|
||||
@@ -70,13 +84,13 @@ public:
|
||||
{
|
||||
rl_readline_name = "sdcv";
|
||||
using_history();
|
||||
const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||
const std::string histname = get_hist_file_path();
|
||||
read_history(histname.c_str());
|
||||
}
|
||||
|
||||
~real_readline()
|
||||
{
|
||||
const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||
const std::string histname = get_hist_file_path();
|
||||
write_history(histname.c_str());
|
||||
const gchar *hist_size_str = g_getenv("SDCV_HISTSIZE");
|
||||
int hist_size;
|
||||
@@ -102,7 +116,7 @@ public:
|
||||
add_history(phrase.c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
#endif //WITH_READLINE
|
||||
|
||||
IReadLine *create_readline_object()
|
||||
|
||||
47
src/sdcv.cpp
47
src/sdcv.cpp
@@ -53,7 +53,7 @@ static void free_str_array(gchar **arr)
|
||||
g_free(*p);
|
||||
g_free(arr);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
namespace glib
|
||||
{
|
||||
using StrArr = ResourceWrapper<gchar *, gchar *, free_str_array>;
|
||||
@@ -61,7 +61,8 @@ using StrArr = ResourceWrapper<gchar *, gchar *, free_str_array>;
|
||||
|
||||
static void list_dicts(const std::list<std::string> &dicts_dir_list, bool use_json);
|
||||
|
||||
int main(int argc, char *argv[]) try {
|
||||
int main(int argc, char *argv[])
|
||||
try {
|
||||
setlocale(LC_ALL, "");
|
||||
#if ENABLE_NLS
|
||||
bindtextdomain("sdcv",
|
||||
@@ -82,6 +83,7 @@ int main(int argc, char *argv[]) try {
|
||||
glib::CharStr opt_data_dir;
|
||||
gboolean only_data_dir = FALSE;
|
||||
gboolean colorize = FALSE;
|
||||
glib::StrArr word_list;
|
||||
|
||||
const GOptionEntry entries[] = {
|
||||
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
|
||||
@@ -95,6 +97,8 @@ int main(int argc, char *argv[]) try {
|
||||
_("for use in scripts"), nullptr },
|
||||
{ "json-output", 'j', 0, G_OPTION_ARG_NONE, &json_output,
|
||||
_("print the result formatted as JSON"), nullptr },
|
||||
{ "json", 'j', 0, G_OPTION_ARG_NONE, &json_output,
|
||||
_("print the result formatted as JSON"), nullptr },
|
||||
{ "exact-search", 'e', 0, G_OPTION_ARG_NONE, &no_fuzzy,
|
||||
_("do not fuzzy-search for similar words, only return exact matches"), nullptr },
|
||||
{ "utf8-output", '0', 0, G_OPTION_ARG_NONE, &utf8_output,
|
||||
@@ -108,11 +112,13 @@ int main(int argc, char *argv[]) try {
|
||||
_("only use the dictionaries in data-dir, do not search in user and system directories"), nullptr },
|
||||
{ "color", 'c', 0, G_OPTION_ARG_NONE, &colorize,
|
||||
_("colorize the output"), nullptr },
|
||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, get_addr(word_list),
|
||||
_("search terms"), _(" words") },
|
||||
{},
|
||||
};
|
||||
|
||||
glib::Error error;
|
||||
GOptionContext *context = g_option_context_new(_(" words"));
|
||||
GOptionContext *context = g_option_context_new(nullptr);
|
||||
g_option_context_set_help_enabled(context, TRUE);
|
||||
g_option_context_add_main_entries(context, entries, nullptr);
|
||||
const gboolean parse_res = g_option_context_parse(context, &argc, &argv, get_addr(error));
|
||||
@@ -141,13 +147,13 @@ int main(int argc, char *argv[]) try {
|
||||
data_dir = get_impl(opt_data_dir);
|
||||
}
|
||||
|
||||
const char *homedir = g_getenv("HOME");
|
||||
if (!homedir)
|
||||
homedir = g_get_home_dir();
|
||||
std::string conf_dir = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".stardict";
|
||||
if (!g_file_test(conf_dir.c_str(), G_FILE_TEST_IS_DIR))
|
||||
conf_dir = std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict";
|
||||
|
||||
std::list<std::string> dicts_dir_list;
|
||||
if (!only_data_dir)
|
||||
dicts_dir_list.push_back(std::string(homedir) + G_DIR_SEPARATOR + ".stardict" + G_DIR_SEPARATOR + "dic");
|
||||
dicts_dir_list.push_back(conf_dir + G_DIR_SEPARATOR + "dic");
|
||||
dicts_dir_list.push_back(data_dir);
|
||||
if (show_list_dicts) {
|
||||
list_dicts(dicts_dir_list, json_output);
|
||||
@@ -186,8 +192,12 @@ int main(int argc, char *argv[]) try {
|
||||
++p;
|
||||
}
|
||||
} else {
|
||||
const std::string odering_cfg_file = std::string(homedir) + G_DIR_SEPARATOR_S ".sdcv_ordering";
|
||||
FILE *ordering_file = fopen(odering_cfg_file.c_str(), "r");
|
||||
std::string ordering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
||||
FILE *ordering_file = fopen(ordering_cfg_file.c_str(), "r");
|
||||
if (ordering_file == nullptr) {
|
||||
ordering_cfg_file = std::string(g_get_home_dir()) + G_DIR_SEPARATOR_S ".sdcv_ordering";
|
||||
ordering_file = fopen(ordering_cfg_file.c_str(), "r");
|
||||
}
|
||||
if (ordering_file != nullptr) {
|
||||
std::string line;
|
||||
while (stdio_getline(ordering_file, line)) {
|
||||
@@ -197,7 +207,6 @@ int main(int argc, char *argv[]) try {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string conf_dir = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".stardict";
|
||||
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST) {
|
||||
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
||||
}
|
||||
@@ -206,16 +215,22 @@ int main(int argc, char *argv[]) try {
|
||||
lib.load(dicts_dir_list, order_list, disable_list);
|
||||
|
||||
std::unique_ptr<IReadLine> io(create_readline_object());
|
||||
if (optind < argc) {
|
||||
for (int i = optind; i < argc; ++i)
|
||||
if (!lib.process_phrase(argv[i], *io, non_interactive)) {
|
||||
return EXIT_FAILURE;
|
||||
if (word_list != nullptr) {
|
||||
search_result rval = SEARCH_SUCCESS;
|
||||
gchar **p = get_impl(word_list);
|
||||
while (*p) {
|
||||
search_result this_rval = lib.process_phrase(*p++, *io, non_interactive);
|
||||
// If we encounter any error, save it but continue through the word
|
||||
// list to check all requested words.
|
||||
if (rval == SEARCH_SUCCESS)
|
||||
rval = this_rval;
|
||||
}
|
||||
if (rval != SEARCH_SUCCESS)
|
||||
return rval;
|
||||
} else if (!non_interactive) {
|
||||
|
||||
std::string phrase;
|
||||
while (io->read(_("Enter word or phrase: "), phrase)) {
|
||||
if (!lib.process_phrase(phrase.c_str(), *io))
|
||||
if (lib.process_phrase(phrase.c_str(), *io) == SEARCH_FAILURE)
|
||||
return EXIT_FAILURE;
|
||||
phrase.clear();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
@@ -71,115 +72,100 @@ static void unicode_strdown(gunichar *str)
|
||||
++str;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool DictInfo::load_from_ifo_file(const std::string &ifofilename,
|
||||
bool istreedict)
|
||||
{
|
||||
ifo_file_name = ifofilename;
|
||||
glib::CharStr buffer;
|
||||
if (!g_file_get_contents(ifofilename.c_str(), get_addr(buffer), nullptr, nullptr))
|
||||
gsize length = 0;
|
||||
if (!g_file_get_contents(ifofilename.c_str(), get_addr(buffer), &length, nullptr)) {
|
||||
fprintf(stderr, "Can not read from %s\n", ifofilename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char TREEDICT_MAGIC_DATA[] = "StarDict's treedict ifo file";
|
||||
static const char DICT_MAGIC_DATA[] = "StarDict's dict ifo file";
|
||||
|
||||
const gchar *magic_data = istreedict ? TREEDICT_MAGIC_DATA : DICT_MAGIC_DATA;
|
||||
static const unsigned char utf8_bom[] = { 0xEF, 0xBB, 0xBF, '\0' };
|
||||
if (!g_str_has_prefix(
|
||||
g_str_has_prefix(get_impl(buffer), (const gchar *)(utf8_bom)) ? get_impl(buffer) + 3 : get_impl(buffer),
|
||||
magic_data)) {
|
||||
static const gchar utf8_bom[] = { (gchar)0xEF, (gchar)0xBB, (gchar)0xBF, '\0' };
|
||||
|
||||
const gchar *p = get_impl(buffer);
|
||||
const gchar *end = p + length;
|
||||
|
||||
if (g_str_has_prefix(p, utf8_bom)) {
|
||||
p += strlen(utf8_bom);
|
||||
}
|
||||
if (!g_str_has_prefix(p, magic_data)) {
|
||||
fprintf(stderr, "No magic header(%s) in ifo file\n", magic_data);
|
||||
return false;
|
||||
}
|
||||
p += strlen(magic_data);
|
||||
|
||||
gchar *p1 = get_impl(buffer) + strlen(magic_data) - 1;
|
||||
|
||||
gchar *p2 = strstr(p1, "\nwordcount=");
|
||||
if (p2 == nullptr)
|
||||
std::map<std::string, std::string> key_value_map;
|
||||
while (p != end) {
|
||||
auto key_it = std::find_if(p, end, [](gchar ch) { return !g_ascii_isspace(ch); });
|
||||
if (key_it == end) {
|
||||
break;
|
||||
}
|
||||
auto eq_it = std::find(key_it, end, gchar('='));
|
||||
if (eq_it == end) {
|
||||
fprintf(stderr, "Invalid part of ifo (no '=') here: %s\n", key_it);
|
||||
return false;
|
||||
}
|
||||
auto val_it = std::find_if(eq_it + 1, end, [](gchar ch) { return !g_ascii_isspace(ch); });
|
||||
if (val_it == end) {
|
||||
key_value_map.insert(std::make_pair(std::string(key_it, eq_it), std::string()));
|
||||
break;
|
||||
}
|
||||
|
||||
gchar *p3 = strchr(p2 + sizeof("\nwordcount=") - 1, '\n');
|
||||
auto line_end_it = std::find_if(val_it, end, [](gchar ch) { return ch == '\r' || ch == '\n'; });
|
||||
key_value_map.insert(std::make_pair(std::string(key_it, eq_it), std::string(val_it, line_end_it)));
|
||||
if (line_end_it == end)
|
||||
break;
|
||||
p = line_end_it + 1;
|
||||
}
|
||||
|
||||
wordcount = atol(std::string(p2 + sizeof("\nwordcount=") - 1, p3 - (p2 + sizeof("\nwordcount=") - 1)).c_str());
|
||||
std::map<std::string, std::string>::const_iterator it;
|
||||
#define FIND_KEY(_key_) \
|
||||
it = key_value_map.find(_key_); \
|
||||
if (it == key_value_map.end()) { \
|
||||
fprintf(stderr, "Can not find '%s' in ifo file\n", _key_); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
FIND_KEY("wordcount")
|
||||
wordcount = atol(it->second.c_str());
|
||||
|
||||
if (istreedict) {
|
||||
p2 = strstr(p1, "\ntdxfilesize=");
|
||||
if (p2 == nullptr)
|
||||
return false;
|
||||
|
||||
p3 = strchr(p2 + sizeof("\ntdxfilesize=") - 1, '\n');
|
||||
|
||||
index_file_size = atol(std::string(p2 + sizeof("\ntdxfilesize=") - 1, p3 - (p2 + sizeof("\ntdxfilesize=") - 1)).c_str());
|
||||
|
||||
FIND_KEY("tdxfilesize")
|
||||
index_file_size = atol(it->second.c_str());
|
||||
} else {
|
||||
FIND_KEY("idxfilesize")
|
||||
index_file_size = atol(it->second.c_str());
|
||||
}
|
||||
FIND_KEY("bookname")
|
||||
bookname = it->second;
|
||||
|
||||
p2 = strstr(p1, "\nidxfilesize=");
|
||||
if (p2 == nullptr)
|
||||
return false;
|
||||
|
||||
p3 = strchr(p2 + sizeof("\nidxfilesize=") - 1, '\n');
|
||||
index_file_size = atol(std::string(p2 + sizeof("\nidxfilesize=") - 1, p3 - (p2 + sizeof("\nidxfilesize=") - 1)).c_str());
|
||||
#define SET_IF_EXISTS(_key_) \
|
||||
it = key_value_map.find(#_key_); \
|
||||
if (it != key_value_map.end()) { \
|
||||
_key_ = it->second; \
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\nbookname=");
|
||||
|
||||
if (p2 == nullptr)
|
||||
return false;
|
||||
|
||||
p2 = p2 + sizeof("\nbookname=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
bookname.assign(p2, p3 - p2);
|
||||
|
||||
p2 = strstr(p1, "\nauthor=");
|
||||
if (p2) {
|
||||
p2 = p2 + sizeof("\nauthor=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
author.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\nemail=");
|
||||
if (p2) {
|
||||
p2 = p2 + sizeof("\nemail=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
email.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\nwebsite=");
|
||||
if (p2) {
|
||||
p2 = p2 + sizeof("\nwebsite=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
website.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\ndate=");
|
||||
if (p2) {
|
||||
p2 = p2 + sizeof("\ndate=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
date.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\ndescription=");
|
||||
if (p2) {
|
||||
p2 = p2 + sizeof("\ndescription=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
description.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\nsametypesequence=");
|
||||
if (p2) {
|
||||
p2 += sizeof("\nsametypesequence=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
sametypesequence.assign(p2, p3 - p2);
|
||||
}
|
||||
|
||||
p2 = strstr(p1, "\nsynwordcount=");
|
||||
SET_IF_EXISTS(author)
|
||||
SET_IF_EXISTS(email)
|
||||
SET_IF_EXISTS(website)
|
||||
SET_IF_EXISTS(date)
|
||||
SET_IF_EXISTS(description)
|
||||
SET_IF_EXISTS(sametypesequence)
|
||||
syn_wordcount = 0;
|
||||
if (p2) {
|
||||
p2 += sizeof("\nsynwordcount=") - 1;
|
||||
p3 = strchr(p2, '\n');
|
||||
syn_wordcount = atol(std::string(p2, p3 - p2).c_str());
|
||||
}
|
||||
|
||||
it = key_value_map.find("synwordcount");
|
||||
if (it != key_value_map.end())
|
||||
syn_wordcount = atol(it->second.c_str());
|
||||
#undef FIND_KEY
|
||||
#undef SET_IF_EXISTS
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -334,6 +320,7 @@ bool DictBase::SearchData(std::vector<std::string> &SearchWords, guint32 idxitem
|
||||
|
||||
if (dictfile)
|
||||
fseek(dictfile, idxitem_offset, SEEK_SET);
|
||||
THROW_IF_ERROR(origin_data != nullptr);
|
||||
if (dictfile) {
|
||||
const size_t nitems = fread(origin_data, idxitem_size, 1, dictfile);
|
||||
THROW_IF_ERROR(nitems == 1);
|
||||
@@ -449,7 +436,7 @@ public:
|
||||
{
|
||||
return get_key(idx);
|
||||
}
|
||||
bool lookup(const char *str, glong &idx) override;
|
||||
bool lookup(const char *str, std::set<glong> &idxs, glong &next_idx) override;
|
||||
|
||||
private:
|
||||
static const gint ENTR_PER_PAGE = 32;
|
||||
@@ -491,7 +478,8 @@ private:
|
||||
static std::list<std::string> get_cache_variant(const std::string &url);
|
||||
};
|
||||
|
||||
const char *OffsetIndex::CACHE_MAGIC = "StarDict's Cache, Version: 0.1";
|
||||
const char *OffsetIndex::CACHE_MAGIC = "StarDict's Cache, Version: 0.2";
|
||||
#define CACHE_MAGIC_BYTES 0x51a4d1c1
|
||||
|
||||
class WordListIndex : public IIndexFile
|
||||
{
|
||||
@@ -509,7 +497,7 @@ public:
|
||||
get_data(idx);
|
||||
return get_key(idx);
|
||||
}
|
||||
bool lookup(const char *str, glong &idx) override;
|
||||
bool lookup(const char *str, std::set<glong> &idxs, glong &next_idx) override;
|
||||
|
||||
private:
|
||||
gchar *idxdatabuf;
|
||||
@@ -573,7 +561,11 @@ bool OffsetIndex::load_cache(const std::string &url)
|
||||
continue;
|
||||
if (strncmp(mf.begin(), CACHE_MAGIC, strlen(CACHE_MAGIC)) != 0)
|
||||
continue;
|
||||
memcpy(&wordoffset[0], mf.begin() + strlen(CACHE_MAGIC), wordoffset.size() * sizeof(wordoffset[0]));
|
||||
guint32 tmp;
|
||||
memcpy(&tmp, mf.begin() + strlen(CACHE_MAGIC), sizeof(tmp));
|
||||
if (tmp != CACHE_MAGIC_BYTES)
|
||||
continue;
|
||||
memcpy(&wordoffset[0], mf.begin() + strlen(CACHE_MAGIC) + sizeof(guint32), wordoffset.size() * sizeof(wordoffset[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -605,10 +597,13 @@ bool OffsetIndex::save_cache(const std::string &url, bool verbose)
|
||||
const std::list<std::string> vars = get_cache_variant(url);
|
||||
for (const std::string &item : vars) {
|
||||
FILE *out = fopen(item.c_str(), "wb");
|
||||
guint32 magic = CACHE_MAGIC_BYTES;
|
||||
if (!out)
|
||||
continue;
|
||||
if (fwrite(CACHE_MAGIC, 1, strlen(CACHE_MAGIC), out) != strlen(CACHE_MAGIC))
|
||||
continue;
|
||||
if (fwrite(&magic, 1, sizeof(magic), out) != sizeof(magic))
|
||||
continue;
|
||||
if (fwrite(&wordoffset[0], sizeof(wordoffset[0]), wordoffset.size(), out) != wordoffset.size())
|
||||
continue;
|
||||
fclose(out);
|
||||
@@ -689,47 +684,52 @@ const gchar *OffsetIndex::get_key(glong idx)
|
||||
return page.entries[idx_in_page].keystr;
|
||||
}
|
||||
|
||||
bool OffsetIndex::lookup(const char *str, glong &idx)
|
||||
bool OffsetIndex::lookup(const char *str, std::set<glong> &idxs, glong &next_idx)
|
||||
{
|
||||
bool bFound = false;
|
||||
glong iFrom;
|
||||
glong iTo = wordoffset.size() - 2;
|
||||
gint cmpint;
|
||||
glong iThisIndex;
|
||||
|
||||
if (stardict_strcmp(str, first.keystr.c_str()) < 0) {
|
||||
idx = 0;
|
||||
next_idx = 0;
|
||||
return false;
|
||||
} else if (stardict_strcmp(str, real_last.keystr.c_str()) > 0) {
|
||||
idx = INVALID_INDEX;
|
||||
next_idx = INVALID_INDEX;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Search for the first page where the word is likely to be located.
|
||||
glong iFrom = 0, iTo = wordoffset.size() - 2;
|
||||
glong iPage = 0, iThisIndex = 0;
|
||||
while (iFrom <= iTo) {
|
||||
iThisIndex = (iFrom + iTo) / 2;
|
||||
glong cmpint = stardict_strcmp(str, get_first_on_page_key(iThisIndex));
|
||||
if (cmpint > 0)
|
||||
iFrom = iThisIndex + 1;
|
||||
else if (cmpint < 0)
|
||||
iTo = iThisIndex - 1;
|
||||
else {
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFound) {
|
||||
// We can use this found index (even though it might not be the first)
|
||||
// because we will search backwards later and catch any entries on
|
||||
// previous pages.
|
||||
iPage = iThisIndex;
|
||||
iThisIndex = 0; // first item in the page
|
||||
} else {
|
||||
iPage = iTo; // prev
|
||||
// Not found at the start of a page, so search within the page that
|
||||
// should contain it. Binary search here is slightly overkill (we're
|
||||
// searching at most ENTR_PER_PAGE = 32 elements) but this way next_idx
|
||||
// is treated the same as other Lookup methods.
|
||||
gulong netr = load_page(iPage);
|
||||
iFrom = 0;
|
||||
iThisIndex = 0;
|
||||
while (iFrom <= iTo) {
|
||||
iThisIndex = (iFrom + iTo) / 2;
|
||||
cmpint = stardict_strcmp(str, get_first_on_page_key(iThisIndex));
|
||||
if (cmpint > 0)
|
||||
iFrom = iThisIndex + 1;
|
||||
else if (cmpint < 0)
|
||||
iTo = iThisIndex - 1;
|
||||
else {
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
idx = iTo; //prev
|
||||
else
|
||||
idx = iThisIndex;
|
||||
}
|
||||
if (!bFound) {
|
||||
gulong netr = load_page(idx);
|
||||
iFrom = 1; // Needn't search the first word anymore.
|
||||
iTo = netr - 1;
|
||||
iThisIndex = 0;
|
||||
while (iFrom <= iTo) {
|
||||
iThisIndex = (iFrom + iTo) / 2;
|
||||
cmpint = stardict_strcmp(str, page.entries[iThisIndex].keystr);
|
||||
glong cmpint = stardict_strcmp(str, page.entries[iThisIndex].keystr);
|
||||
if (cmpint > 0)
|
||||
iFrom = iThisIndex + 1;
|
||||
else if (cmpint < 0)
|
||||
@@ -739,18 +739,26 @@ bool OffsetIndex::lookup(const char *str, glong &idx)
|
||||
break;
|
||||
}
|
||||
}
|
||||
idx *= ENTR_PER_PAGE;
|
||||
}
|
||||
|
||||
if (!bFound)
|
||||
idx += iFrom; //next
|
||||
else
|
||||
idx += iThisIndex;
|
||||
} else {
|
||||
idx *= ENTR_PER_PAGE;
|
||||
next_idx = iPage * ENTR_PER_PAGE + iFrom; // next
|
||||
else {
|
||||
// Convert the found in-page index to the dict index.
|
||||
iThisIndex = iPage * ENTR_PER_PAGE + iThisIndex;
|
||||
// In order to return all idxs that match the search string, walk
|
||||
// linearly behind and ahead of the found index.
|
||||
glong iHeadIndex = iThisIndex - 1; // do not include iThisIndex
|
||||
while (iHeadIndex >= 0 && stardict_strcmp(str, get_key(iHeadIndex)) == 0)
|
||||
idxs.insert(iHeadIndex--);
|
||||
do // no need to double-check iThisIndex -- we know it's a match already
|
||||
idxs.insert(iThisIndex++);
|
||||
while (iThisIndex <= real_last.idx && stardict_strcmp(str, get_key(iThisIndex)) == 0);
|
||||
}
|
||||
return bFound;
|
||||
}
|
||||
|
||||
bool WordListIndex::load(const std::string &url, gulong wc, gulong fsize, bool verbose)
|
||||
bool WordListIndex::load(const std::string &url, gulong wc, gulong fsize, bool)
|
||||
{
|
||||
gzFile in = gzopen(url.c_str(), "rb");
|
||||
if (in == nullptr)
|
||||
@@ -786,18 +794,18 @@ void WordListIndex::get_data(glong idx)
|
||||
wordentry_size = g_ntohl(get_uint32(p1));
|
||||
}
|
||||
|
||||
bool WordListIndex::lookup(const char *str, glong &idx)
|
||||
bool WordListIndex::lookup(const char *str, std::set<glong> &idxs, glong &next_idx)
|
||||
{
|
||||
bool bFound = false;
|
||||
glong iTo = wordlist.size() - 2;
|
||||
glong iLast = wordlist.size() - 2;
|
||||
|
||||
if (stardict_strcmp(str, get_key(0)) < 0) {
|
||||
idx = 0;
|
||||
} else if (stardict_strcmp(str, get_key(iTo)) > 0) {
|
||||
idx = INVALID_INDEX;
|
||||
next_idx = 0;
|
||||
} else if (stardict_strcmp(str, get_key(iLast)) > 0) {
|
||||
next_idx = INVALID_INDEX;
|
||||
} else {
|
||||
glong iThisIndex = 0;
|
||||
glong iFrom = 0;
|
||||
glong iFrom = 0, iTo = iLast;
|
||||
gint cmpint;
|
||||
while (iFrom <= iTo) {
|
||||
iThisIndex = (iFrom + iTo) / 2;
|
||||
@@ -812,53 +820,102 @@ bool WordListIndex::lookup(const char *str, glong &idx)
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
idx = iFrom; //next
|
||||
else
|
||||
idx = iThisIndex;
|
||||
next_idx = iFrom; // next
|
||||
else {
|
||||
// In order to return all idxs that match the search string, walk
|
||||
// linearly behind and ahead of the found index.
|
||||
glong iHeadIndex = iThisIndex - 1; // do not include iThisIndex
|
||||
while (iHeadIndex >= 0 && stardict_strcmp(str, get_key(iHeadIndex)) == 0)
|
||||
idxs.insert(iHeadIndex--);
|
||||
do // no need to double-check iThisIndex -- we know it's a match already
|
||||
idxs.insert(iThisIndex++);
|
||||
while (iThisIndex <= iLast && stardict_strcmp(str, get_key(iThisIndex)) == 0);
|
||||
}
|
||||
}
|
||||
return bFound;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool SynFile::load(const std::string &url, gulong wc)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
if (!stat(url.c_str(), &stat_buf)) {
|
||||
MapFile syn;
|
||||
if (!syn.open(url.c_str(), stat_buf.st_size))
|
||||
|
||||
if (!synfile.open(url.c_str(), stat_buf.st_size))
|
||||
return false;
|
||||
const gchar *current = syn.begin();
|
||||
|
||||
synlist.resize(wc + 1);
|
||||
gchar *p1 = synfile.begin();
|
||||
|
||||
for (unsigned long i = 0; i < wc; i++) {
|
||||
// each entry in a syn-file is:
|
||||
// - 0-terminated string
|
||||
// 4-byte index into .dict file in network byte order
|
||||
glib::CharStr lower_string{ g_utf8_casefold(current, -1) };
|
||||
std::string synonym{ get_impl(lower_string) };
|
||||
current += synonym.length() + 1;
|
||||
const guint32 idx = g_ntohl(get_uint32(current));
|
||||
current += sizeof(idx);
|
||||
synonyms[synonym] = idx;
|
||||
|
||||
synlist[i] = p1;
|
||||
p1 += strlen(p1) + 1 + 4;
|
||||
}
|
||||
synlist[wc] = p1;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SynFile::lookup(const char *str, glong &idx)
|
||||
bool SynFile::lookup(const char *str, std::set<glong> &idxs, glong &next_idx)
|
||||
{
|
||||
glib::CharStr lower_string{ g_utf8_casefold(str, -1) };
|
||||
auto it = synonyms.find(get_impl(lower_string));
|
||||
if (it != synonyms.end()) {
|
||||
idx = it->second;
|
||||
return true;
|
||||
}
|
||||
bool bFound = false;
|
||||
glong iLast = synlist.size() - 2;
|
||||
if (iLast < 0)
|
||||
return false;
|
||||
|
||||
if (stardict_strcmp(str, get_key(0)) < 0) {
|
||||
next_idx = 0;
|
||||
} else if (stardict_strcmp(str, get_key(iLast)) > 0) {
|
||||
next_idx = INVALID_INDEX;
|
||||
} else {
|
||||
glong iThisIndex = 0;
|
||||
glong iFrom = 0, iTo = iLast;
|
||||
gint cmpint;
|
||||
while (iFrom <= iTo) {
|
||||
iThisIndex = (iFrom + iTo) / 2;
|
||||
cmpint = stardict_strcmp(str, get_key(iThisIndex));
|
||||
if (cmpint > 0)
|
||||
iFrom = iThisIndex + 1;
|
||||
else if (cmpint < 0)
|
||||
iTo = iThisIndex - 1;
|
||||
else {
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
next_idx = iFrom; // next
|
||||
else {
|
||||
// In order to return all idxs that match the search string, walk
|
||||
// linearly behind and ahead of the found index.
|
||||
glong iHeadIndex = iThisIndex - 1; // do not include iThisIndex
|
||||
while (iHeadIndex >= 0 && stardict_strcmp(str, get_key(iHeadIndex)) == 0) {
|
||||
const gchar *key = get_key(iHeadIndex--);
|
||||
idxs.insert(g_ntohl(get_uint32(key + strlen(key) + 1)));
|
||||
}
|
||||
do {
|
||||
// no need to double-check iThisIndex -- we know it's a match already
|
||||
const gchar *key = get_key(iThisIndex++);
|
||||
idxs.insert(g_ntohl(get_uint32(key + strlen(key) + 1)));
|
||||
} while (iThisIndex <= iLast && stardict_strcmp(str, get_key(iThisIndex)) == 0);
|
||||
}
|
||||
}
|
||||
return bFound;
|
||||
}
|
||||
|
||||
bool Dict::Lookup(const char *str, glong &idx)
|
||||
bool Dict::Lookup(const char *str, std::set<glong> &idxs, glong &next_idx)
|
||||
{
|
||||
return syn_file->lookup(str, idx) || idx_file->lookup(str, idx);
|
||||
bool found = false;
|
||||
found |= syn_file->lookup(str, idxs, next_idx);
|
||||
found |= idx_file->lookup(str, idxs, next_idx);
|
||||
return found;
|
||||
}
|
||||
|
||||
bool Dict::load(const std::string &ifofilename, bool verbose)
|
||||
@@ -966,120 +1023,8 @@ void Libs::load(const std::list<std::string> &dicts_dirs,
|
||||
});
|
||||
}
|
||||
|
||||
const gchar *Libs::poGetCurrentWord(glong *iCurrent)
|
||||
bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib)
|
||||
{
|
||||
const gchar *poCurrentWord = nullptr;
|
||||
const gchar *word;
|
||||
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
|
||||
if (iCurrent[iLib] == INVALID_INDEX)
|
||||
continue;
|
||||
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
|
||||
continue;
|
||||
if (poCurrentWord == nullptr) {
|
||||
poCurrentWord = poGetWord(iCurrent[iLib], iLib);
|
||||
} else {
|
||||
word = poGetWord(iCurrent[iLib], iLib);
|
||||
|
||||
if (stardict_strcmp(poCurrentWord, word) > 0)
|
||||
poCurrentWord = word;
|
||||
}
|
||||
}
|
||||
return poCurrentWord;
|
||||
}
|
||||
|
||||
const gchar *Libs::poGetNextWord(const gchar *sWord, glong *iCurrent)
|
||||
{
|
||||
// the input can be:
|
||||
// (word,iCurrent),read word,write iNext to iCurrent,and return next word. used by TopWin::NextCallback();
|
||||
// (nullptr,iCurrent),read iCurrent,write iNext to iCurrent,and return next word. used by AppCore::ListWords();
|
||||
const gchar *poCurrentWord = nullptr;
|
||||
size_t iCurrentLib = 0;
|
||||
const gchar *word;
|
||||
|
||||
for (size_t iLib = 0; iLib < oLib.size(); ++iLib) {
|
||||
if (sWord)
|
||||
oLib[iLib]->Lookup(sWord, iCurrent[iLib]);
|
||||
if (iCurrent[iLib] == INVALID_INDEX)
|
||||
continue;
|
||||
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
|
||||
continue;
|
||||
if (poCurrentWord == nullptr) {
|
||||
poCurrentWord = poGetWord(iCurrent[iLib], iLib);
|
||||
iCurrentLib = iLib;
|
||||
} else {
|
||||
word = poGetWord(iCurrent[iLib], iLib);
|
||||
|
||||
if (stardict_strcmp(poCurrentWord, word) > 0) {
|
||||
poCurrentWord = word;
|
||||
iCurrentLib = iLib;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (poCurrentWord) {
|
||||
iCurrent[iCurrentLib]++;
|
||||
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
|
||||
if (iLib == iCurrentLib)
|
||||
continue;
|
||||
if (iCurrent[iLib] == INVALID_INDEX)
|
||||
continue;
|
||||
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
|
||||
continue;
|
||||
if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib], iLib)) == 0)
|
||||
iCurrent[iLib]++;
|
||||
}
|
||||
poCurrentWord = poGetCurrentWord(iCurrent);
|
||||
}
|
||||
return poCurrentWord;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
Libs::poGetPreWord(glong *iCurrent)
|
||||
{
|
||||
// used by TopWin::PreviousCallback(); the iCurrent is cached by AppCore::TopWinWordChange();
|
||||
const gchar *poCurrentWord = nullptr;
|
||||
std::vector<Dict *>::size_type iCurrentLib = 0;
|
||||
const gchar *word;
|
||||
|
||||
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
|
||||
if (iCurrent[iLib] == INVALID_INDEX)
|
||||
iCurrent[iLib] = narticles(iLib);
|
||||
else {
|
||||
if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0)
|
||||
continue;
|
||||
}
|
||||
if (poCurrentWord == nullptr) {
|
||||
poCurrentWord = poGetWord(iCurrent[iLib] - 1, iLib);
|
||||
iCurrentLib = iLib;
|
||||
} else {
|
||||
word = poGetWord(iCurrent[iLib] - 1, iLib);
|
||||
if (stardict_strcmp(poCurrentWord, word) < 0) {
|
||||
poCurrentWord = word;
|
||||
iCurrentLib = iLib;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (poCurrentWord) {
|
||||
iCurrent[iCurrentLib]--;
|
||||
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
|
||||
if (iLib == iCurrentLib)
|
||||
continue;
|
||||
if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0)
|
||||
continue;
|
||||
if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib] - 1, iLib)) == 0) {
|
||||
iCurrent[iLib]--;
|
||||
} else {
|
||||
if (iCurrent[iLib] == narticles(iLib))
|
||||
iCurrent[iLib] = INVALID_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
return poCurrentWord;
|
||||
}
|
||||
|
||||
bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
{
|
||||
glong iIndex;
|
||||
bool bFound = false;
|
||||
gchar *casestr;
|
||||
|
||||
@@ -1087,7 +1032,7 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
// to lower case.
|
||||
casestr = g_utf8_strdown(sWord, -1);
|
||||
if (strcmp(casestr, sWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1095,7 +1040,7 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (!bFound) {
|
||||
casestr = g_utf8_strup(sWord, -1);
|
||||
if (strcmp(casestr, sWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1109,7 +1054,7 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
g_free(firstchar);
|
||||
g_free(nextchar);
|
||||
if (strcmp(casestr, sWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1129,12 +1074,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (isupcase || sWord[iWordLen - 1] == 's' || !strncmp(&sWord[iWordLen - 2], "ed", 2)) {
|
||||
strcpy(sNewWord, sWord);
|
||||
sNewWord[iWordLen - 1] = '\0'; // cut "s" or "d"
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1152,13 +1097,13 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
&& !bIsVowel(sNewWord[iWordLen - 4]) && bIsVowel(sNewWord[iWordLen - 5])) { // doubled
|
||||
|
||||
sNewWord[iWordLen - 3] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else {
|
||||
if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1168,12 +1113,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
}
|
||||
}
|
||||
if (!bFound) {
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1191,13 +1136,13 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (iWordLen > 6 && (sNewWord[iWordLen - 4] == sNewWord[iWordLen - 5])
|
||||
&& !bIsVowel(sNewWord[iWordLen - 5]) && bIsVowel(sNewWord[iWordLen - 6])) { // doubled
|
||||
sNewWord[iWordLen - 4] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else {
|
||||
if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1207,12 +1152,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
}
|
||||
}
|
||||
if (!bFound) {
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1223,12 +1168,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
strcat(sNewWord, "E"); // add a char "E"
|
||||
else
|
||||
strcat(sNewWord, "e"); // add a char "e"
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1243,12 +1188,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (isupcase || (!strncmp(&sWord[iWordLen - 2], "es", 2) && (sWord[iWordLen - 3] == 's' || sWord[iWordLen - 3] == 'x' || sWord[iWordLen - 3] == 'o' || (iWordLen > 4 && sWord[iWordLen - 3] == 'h' && (sWord[iWordLen - 4] == 'c' || sWord[iWordLen - 4] == 's'))))) {
|
||||
strcpy(sNewWord, sWord);
|
||||
sNewWord[iWordLen - 2] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1265,13 +1210,13 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (iWordLen > 5 && (sNewWord[iWordLen - 3] == sNewWord[iWordLen - 4])
|
||||
&& !bIsVowel(sNewWord[iWordLen - 4]) && bIsVowel(sNewWord[iWordLen - 5])) { // doubled
|
||||
sNewWord[iWordLen - 3] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else {
|
||||
if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1281,12 +1226,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
}
|
||||
}
|
||||
if (!bFound) {
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1305,12 +1250,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
strcat(sNewWord, "Y"); // add a char "Y"
|
||||
else
|
||||
strcat(sNewWord, "y"); // add a char "y"
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1328,12 +1273,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
strcat(sNewWord, "Y"); // add a char "Y"
|
||||
else
|
||||
strcat(sNewWord, "y"); // add a char "y"
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1347,12 +1292,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (isupcase || (!strncmp(&sWord[iWordLen - 2], "er", 2))) {
|
||||
strcpy(sNewWord, sWord);
|
||||
sNewWord[iWordLen - 2] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1366,12 +1311,12 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
if (isupcase || (!strncmp(&sWord[iWordLen - 3], "est", 3))) {
|
||||
strcpy(sNewWord, sWord);
|
||||
sNewWord[iWordLen - 3] = '\0';
|
||||
if (oLib[iLib]->Lookup(sNewWord, iIndex))
|
||||
if (oLib[iLib]->Lookup(sNewWord, iWordIndices))
|
||||
bFound = true;
|
||||
else if (isupcase || g_ascii_isupper(sWord[0])) {
|
||||
casestr = g_ascii_strdown(sNewWord, -1);
|
||||
if (strcmp(casestr, sNewWord)) {
|
||||
if (oLib[iLib]->Lookup(casestr, iIndex))
|
||||
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||
bFound = true;
|
||||
}
|
||||
g_free(casestr);
|
||||
@@ -1381,9 +1326,6 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
|
||||
g_free(sNewWord);
|
||||
}
|
||||
|
||||
if (bFound)
|
||||
iWordIndex = iIndex;
|
||||
#if 0
|
||||
else {
|
||||
//don't change iWordIndex here.
|
||||
@@ -1394,11 +1336,11 @@ bool Libs::LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
return bFound;
|
||||
}
|
||||
|
||||
bool Libs::SimpleLookupWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
bool Libs::SimpleLookupWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib)
|
||||
{
|
||||
bool bFound = oLib[iLib]->Lookup(sWord, iWordIndex);
|
||||
bool bFound = oLib[iLib]->Lookup(sWord, iWordIndices);
|
||||
if (!bFound && fuzzy_)
|
||||
bFound = LookupSimilarWord(sWord, iWordIndex, iLib);
|
||||
bFound = LookupSimilarWord(sWord, iWordIndices, iLib);
|
||||
return bFound;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -96,17 +95,27 @@ public:
|
||||
virtual const gchar *get_key(glong idx) = 0;
|
||||
virtual void get_data(glong idx) = 0;
|
||||
virtual const gchar *get_key_and_data(glong idx) = 0;
|
||||
virtual bool lookup(const char *str, glong &idx) = 0;
|
||||
virtual bool lookup(const char *str, std::set<glong> &idxs, glong &next_idx) = 0;
|
||||
virtual bool lookup(const char *str, std::set<glong> &idxs)
|
||||
{
|
||||
glong unused_next_idx;
|
||||
return lookup(str, idxs, unused_next_idx);
|
||||
};
|
||||
};
|
||||
|
||||
class SynFile
|
||||
{
|
||||
public:
|
||||
SynFile() {}
|
||||
~SynFile() {}
|
||||
bool load(const std::string &url, gulong wc);
|
||||
bool lookup(const char *str, glong &idx);
|
||||
bool lookup(const char *str, std::set<glong> &idxs, glong &next_idx);
|
||||
bool lookup(const char *str, std::set<glong> &idxs);
|
||||
const gchar *get_key(glong idx) { return synlist[idx]; }
|
||||
|
||||
private:
|
||||
std::map<std::string, gulong> synonyms;
|
||||
MapFile synfile;
|
||||
std::vector<gchar *> synlist;
|
||||
};
|
||||
|
||||
class Dict : public DictBase
|
||||
@@ -133,7 +142,12 @@ public:
|
||||
*offset = idx_file->wordentry_offset;
|
||||
*size = idx_file->wordentry_size;
|
||||
}
|
||||
bool Lookup(const char *str, glong &idx);
|
||||
bool Lookup(const char *str, std::set<glong> &idxs, glong &next_idx);
|
||||
bool Lookup(const char *str, std::set<glong> &idxs)
|
||||
{
|
||||
glong unused_next_idx;
|
||||
return Lookup(str, idxs, unused_next_idx);
|
||||
}
|
||||
|
||||
bool LookupWithRule(GPatternSpec *pspec, glong *aIndex, int iBuffLen);
|
||||
|
||||
@@ -181,15 +195,12 @@ public:
|
||||
return nullptr;
|
||||
return oLib[iLib]->get_data(iIndex);
|
||||
}
|
||||
const gchar *poGetCurrentWord(glong *iCurrent);
|
||||
const gchar *poGetNextWord(const gchar *word, glong *iCurrent);
|
||||
const gchar *poGetPreWord(glong *iCurrent);
|
||||
bool LookupWord(const gchar *sWord, glong &iWordIndex, int iLib)
|
||||
bool LookupWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib)
|
||||
{
|
||||
return oLib[iLib]->Lookup(sWord, iWordIndex);
|
||||
return oLib[iLib]->Lookup(sWord, iWordIndices);
|
||||
}
|
||||
bool LookupSimilarWord(const gchar *sWord, glong &iWordIndex, int iLib);
|
||||
bool SimpleLookupWord(const gchar *sWord, glong &iWordIndex, int iLib);
|
||||
bool LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib);
|
||||
bool SimpleLookupWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib);
|
||||
|
||||
bool LookupWithFuzzy(const gchar *sWord, gchar *reslist[], gint reslist_size);
|
||||
gint LookupWithRule(const gchar *sWord, gchar *reslist[]);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace glib
|
||||
{
|
||||
typedef ResourceWrapper<gchar, void, g_free> CharStr;
|
||||
typedef ResourceWrapper<GError, GError, g_error_free> Error;
|
||||
}
|
||||
} // namespace glib
|
||||
|
||||
extern std::string utf8_to_locale_ign_err(const std::string &utf8_str);
|
||||
|
||||
|
||||
0
tests/not-unix-newlines-ifo/russian/russian.dict
Normal file
0
tests/not-unix-newlines-ifo/russian/russian.dict
Normal file
0
tests/not-unix-newlines-ifo/russian/russian.idx
Normal file
0
tests/not-unix-newlines-ifo/russian/russian.idx
Normal file
9
tests/not-unix-newlines-ifo/russian/russian.ifo
Normal file
9
tests/not-unix-newlines-ifo/russian/russian.ifo
Normal file
@@ -0,0 +1,9 @@
|
||||
StarDict's dict ifo file
|
||||
version=3.0.0
|
||||
bookname=Russian-English Dictionary (ru-en)
|
||||
wordcount=415144
|
||||
idxfilesize=12344255
|
||||
sametypesequence=h
|
||||
synwordcount=1277580
|
||||
author=Vuizur
|
||||
description=
|
||||
0
tests/not-unix-newlines-ifo/russian/russian.syn
Normal file
0
tests/not-unix-newlines-ifo/russian/russian.syn
Normal file
Binary file not shown.
BIN
tests/stardict-test_multiple_results-2.4.2/test.dict
Normal file
BIN
tests/stardict-test_multiple_results-2.4.2/test.dict
Normal file
Binary file not shown.
BIN
tests/stardict-test_multiple_results-2.4.2/test.idx
Normal file
BIN
tests/stardict-test_multiple_results-2.4.2/test.idx
Normal file
Binary file not shown.
7
tests/stardict-test_multiple_results-2.4.2/test.ifo
Normal file
7
tests/stardict-test_multiple_results-2.4.2/test.ifo
Normal file
@@ -0,0 +1,7 @@
|
||||
StarDict's dict ifo file
|
||||
version=3.0.0
|
||||
bookname=Test multiple results
|
||||
wordcount=246
|
||||
idxfilesize=5977
|
||||
synwordcount=124
|
||||
description=
|
||||
BIN
tests/stardict-test_multiple_results-2.4.2/test.syn
Normal file
BIN
tests/stardict-test_multiple_results-2.4.2/test.syn
Normal file
Binary file not shown.
BIN
tests/stardict-test_synonyms-2.4.2/test.idx.oft
Normal file
BIN
tests/stardict-test_synonyms-2.4.2/test.idx.oft
Normal file
Binary file not shown.
@@ -6,7 +6,7 @@ unset SDCV_PAGER
|
||||
have=`"$PATH_TO_SDCV" --data-dir /tmp/bugagaga -l | wc -l`
|
||||
#do not count header
|
||||
have=$(($have-1))
|
||||
ndicts=`find "${HOME}"/.stardict/dic -name "*.ifo" -print | wc -l`
|
||||
ndicts=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" -print | wc -l`
|
||||
#ndicts=$(($ndicts+1))
|
||||
if [ $have -ne $ndicts ]; then
|
||||
ndicts=$(($ndicts-1))
|
||||
|
||||
19
tests/t_json
19
tests/t_json
@@ -9,17 +9,24 @@ unset SDCV_PAGER
|
||||
unset STARDICT_DATA_DIR
|
||||
|
||||
test_json() {
|
||||
PARAMS="$1"
|
||||
EXPECTED=$(echo "$2" | jq 'sort')
|
||||
RESULT=$($SDCV $PARAMS | jq 'sort')
|
||||
EXPECTED=$(echo "$1" | jq 'sort')
|
||||
shift
|
||||
RESULT=$($SDCV "$@" | jq 'sort')
|
||||
if [ "$EXPECTED" != "$RESULT" ]; then
|
||||
echo "expected $EXPECTED but got $RESULT"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_json "-x -j -l -n --data-dir \"$TEST_DIR\"" "[{\"name\": \"Test synonyms\", \"wordcount\": \"1\"},{\"name\": \"Sample 1 test dictionary\", \"wordcount\": \"1\"},{\"name\": \"test_dict\", \"wordcount\": \"1\"}]"
|
||||
test_json "-x -j -n --data-dir \"$TEST_DIR\" foo" "[{\"dict\": \"Test synonyms\",\"word\":\"test\",\"definition\":\"\nresult of test\"}]"
|
||||
test_json "-x -j -n --data-dir \"$TEST_DIR\" foobarbaaz" "[]"
|
||||
test_json '[{"name": "Russian-English Dictionary (ru-en)", "wordcount": "415144"},
|
||||
{"name": "Test synonyms", "wordcount": "2"},
|
||||
{"name": "Test multiple results", "wordcount": "246"},
|
||||
{"name": "Sample 1 test dictionary", "wordcount": "1"},
|
||||
{"name": "test_dict", "wordcount": "1"}]' -x -j -l -n --data-dir "$TEST_DIR"
|
||||
test_json '[{"dict": "Test synonyms","word":"test","definition":"\u000aresult of test"}]' -x -j -n --data-dir "$TEST_DIR" foo
|
||||
test_json '[]' -x -j -n --data-dir "$TEST_DIR" foobarbaaz
|
||||
|
||||
# Test multiple searches, with the first failing.
|
||||
test_json '[][{"dict": "Test synonyms","word":"test","definition":"\u000aresult of test"}]' -x -j -n --data-dir "$TEST_DIR" foobarbaaz foo
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -4,7 +4,7 @@ PATH_TO_SDCV="$1"
|
||||
ndicts=`"$PATH_TO_SDCV" -l | wc -l`
|
||||
ndicts=$(($ndicts-1))
|
||||
ncom=`find /usr/share/stardict/dic -name "*.ifo" | wc -l`
|
||||
nspe=`find "${HOME}"/.stardict/dic -name "*.ifo" | wc -l`
|
||||
nspe=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" | wc -l`
|
||||
nmy=$(($ncom+$nspe))
|
||||
|
||||
if [ $nmy -ne $ndicts ]; then
|
||||
|
||||
67
tests/t_multiple_results
Executable file
67
tests/t_multiple_results
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
SDCV="$1"
|
||||
TEST_DIR="$2"
|
||||
|
||||
unset SDCV_PAGER
|
||||
unset STARDICT_DATA_DIR
|
||||
|
||||
test_json() {
|
||||
word="$1"
|
||||
jq_cmp="$2"
|
||||
result="$("$SDCV" --data-dir "$TEST_DIR" -exjn "$word" | sed 's|\\n|\\u000a|g')"
|
||||
cmp_result="$(echo "$result" | jq "$jq_cmp")"
|
||||
if [ "$cmp_result" != "true" ]; then
|
||||
echo "expected '$jq_cmp' to return true, but $result didn't"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Basic two-result search for the same headword.
|
||||
test_json bark \
|
||||
'. == [
|
||||
{"dict":"Test multiple results","word":"bark","definition":"\u000aThe harsh sound made by a dog."},
|
||||
{"dict":"Test multiple results","word":"bark","definition":"\u000aThe tough outer covering of trees and other woody plants."}
|
||||
]'
|
||||
|
||||
# Multi-result search where one word exists as both a synyonym and a separate
|
||||
# headword. This ensures that if there is a matching synyonym we don't skip the
|
||||
# regular search.
|
||||
test_json cat \
|
||||
'. == [
|
||||
{"dict":"Test multiple results","word":"cat","definition":"\u000aA cute animal which (rarely) barks."},
|
||||
{"dict":"Test multiple results","word":"lion","definition":"\u000aA larger cat which might bite your head off."},
|
||||
{"dict":"Test multiple results","word":"panther","definition":"\u000aI know very little about panthers, sorry."}
|
||||
]'
|
||||
|
||||
# Many-result search for a word that matches 120 distinct headwords.
|
||||
test_json many_headwords 'length == 120'
|
||||
test_json many_headwords 'all(.word == "many_headwords")'
|
||||
test_json many_headwords \
|
||||
'to_entries | map(.value.definition == "\u000aDefinition for [many_headwords] entry #\(.key+1) (same headword).") | all'
|
||||
|
||||
# Many-result search for 120 words that have the same synonym.
|
||||
test_json many_synonyms 'length == 120'
|
||||
test_json many_synonyms \
|
||||
'to_entries | map(.value.word == "many_synonyms-\(.key+101)") | all'
|
||||
test_json many_synonyms \
|
||||
'to_entries | map(.value.definition == "\u000aDefinition for [many_synonyms-\(.key+101)] (same synonym).") | all'
|
||||
|
||||
# Ensure that we don't return more than one result even if a word can be
|
||||
# resolved in more than one way.
|
||||
#
|
||||
# Most well-formed dictionaries don't have entries like this (it basically
|
||||
# requires you to have a dictionary where there is a synonym that is identical
|
||||
# to a word's headword or multiple identical synyonym entries).
|
||||
#
|
||||
# This entry was created by creating extra synonyms with different names then
|
||||
# modifying the .syn file manually.
|
||||
test_json many_resolution_paths \
|
||||
'. == [
|
||||
{"dict":"Test multiple results","word":"many_resolution_paths",
|
||||
"definition":"\u000aDefinition for [many_resolution_paths] headword (same word, multiple synonym entries)."}
|
||||
]'
|
||||
|
||||
exit 0
|
||||
18
tests/t_newlines_in_ifo
Executable file
18
tests/t_newlines_in_ifo
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
PATH_TO_SDCV="$1"
|
||||
TEST_DIR="$2"
|
||||
|
||||
unset SDCV_PAGER
|
||||
unset STARDICT_DATA_DIR
|
||||
|
||||
RES=$("$PATH_TO_SDCV" -n -x --data-dir="$TEST_DIR/not-unix-newlines-ifo" -l | tail -n 1)
|
||||
|
||||
if [ "$RES" = "Russian-English Dictionary (ru-en) 415144" ]; then
|
||||
exit 0
|
||||
else
|
||||
echo "test failed, unexpected result: $RES" >&2
|
||||
exit 1
|
||||
fi
|
||||
22
tests/t_return_code
Executable file
22
tests/t_return_code
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
SDCV="$1"
|
||||
TEST_DIR="$2"
|
||||
|
||||
unset SDCV_PAGER
|
||||
|
||||
test_return_code() {
|
||||
WORD=$1
|
||||
EXPECTED=$2
|
||||
$SDCV -e -n --data-dir "$TEST_DIR" -u "Test synonyms" $WORD > /dev/null
|
||||
RC=$?
|
||||
if [ $RC -ne $EXPECTED ]; then
|
||||
echo "Return code for $WORD should be '$EXPECTED' but was '$RC'"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_return_code testawordy 0
|
||||
test_return_code testawordies 2
|
||||
|
||||
exit 0
|
||||
@@ -5,8 +5,8 @@ set -e
|
||||
PATH_TO_SDCV="$1"
|
||||
TESTS_DIR="$2"
|
||||
|
||||
mkdir -p "${HOME}"/.stardict/dic
|
||||
cp -R "${TESTS_DIR}/stardict-test_dict-2.4.2" "${HOME}"/.stardict/dic
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
cp -R "${TESTS_DIR}/stardict-test_dict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
unset SDCV_PAGER
|
||||
RES=`"$PATH_TO_SDCV" -n -u test_dict test | grep "test passed"`
|
||||
|
||||
@@ -15,6 +15,6 @@ if [ -z "$RES" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -fr "${HOME}"/.stardict/dic/stardict-test_dict-2.4.2
|
||||
rm -fr "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/stardict-test_dict-2.4.2
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -4,9 +4,8 @@ set -e
|
||||
|
||||
PATH_TO_SDCV="$1"
|
||||
TESTS_DIR="$2"
|
||||
|
||||
mkdir -p "${HOME}"/.stardict/dic
|
||||
cp -R "${TESTS_DIR}/rus-eng-stardict-2.4.2" "${HOME}"/.stardict/dic/
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
cp -R "${TESTS_DIR}/rus-eng-stardict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/
|
||||
|
||||
unset SDCV_PAGER
|
||||
export LANG=ru_RU.KOI8-R
|
||||
|
||||
Reference in New Issue
Block a user