Commit Graph

39 Commits (master)

Author SHA1 Message Date
Frans de Jonge 31c28378e7
[i18n] GetText: fix fuzzy detection for certain strings (#11648)
Reported in <https://github.com/koreader/koreader/pull/11647#issue-2233008767>.

Probably overlooked in #5807
2 weeks ago
Frans de Jonge ad266f46c2
GetText: fix crash if a value is used as unique value and as singular/plural (#11643)
Concretely 1 second, %1 seconds since #11549 added `1 second` all by itself.
2 weeks ago
NiLuJe dcb11c2542
Make luacheck >= 0.26 happy (#9174)
Re: https://github.com/koreader/koreader-base/pull/1487
2 years ago
Frans de Jonge a8db251bd8
[chore] Remove leftover debug print (#9080) 2 years ago
Frans de Jonge 8da18d403b
[i18n] Enable Latvian translation (#9079)
Cf. <https://github.com/koreader/koreader/issues/8225#issuecomment-1120181554>.
2 years ago
NiLuJe 23cd7e24bb
Minor Lua I/O cleanups (#8921)
Mostly making sure we always explicitly close io handles.
2 years ago
Frans de Jonge 1c8ab19f83
[fix] gettext: don't replace backslash characters (#8511)
Everything in string.gsub() is replaced, not only the matching group. By using two groups, we can correctly return the full matched string when none of the special conditions apply.

Fixes <https://github.com/koreader/koreader/issues/8486>.
2 years ago
Frans de Jonge 0aab7d7378
[fix] gettext: unescape \\ for ID matching (#8357)
Fixes <https://github.com/koreader/koreader/issues/8356>.
3 years ago
Frans de Jonge 6cc0ab8dc9
[fix] Always initiate empty context table (#6874)
In case of no environment language. I suppose that doesn't tend to happen much in the wild since I added the offending code early in 2020. ;-)

Fixes <https://github.com/koreader/koreader/issues/6873>.
3 years ago
Frans de Jonge 4a3710b6d3
[i18n] Add support for fledgling Hebrew translation (#6333)
See <https://hosted.weblate.org/languages/he/koreader/> if you'd like to contribute.
4 years ago
Frans de Jonge d64e143297
[i18n] GetText: ignore fuzzy strings (#5807)
Strings are prefilled by msgmerge with closely matching ones to reduce the amount of labor required by the translator. Often the string requires only minor adjustment, making the process faster, and when the string isn't a good match it's no big deal. However, these so-called fuzzy strings shouldn't be treated as if they were actually translated.

Fixes the effect seen in <https://github.com/koreader/koreader/issues/5806>.
4 years ago
Frans de Jonge 3436e47367
[fix] Update hardcoded gettext workaround for Romanian (#5718)
Fixes #5661.
4 years ago
poire-z 6596e5ddc7 [RTL UI] GetText/Bidi: wrap untranslated strings in LTR 4 years ago
Mihai Vasiliu 739a3009ff [i18n] Fix Romanian plural forms (#5692)
Hardcode the plural forms logic for Romanian.

This fixes #5661 and enables Romanian (Moldova) language in the menu.
4 years ago
Frans de Jonge 50878eab9e
[fix] Tailor plurals match (#5603)
Fixes #5601.
4 years ago
Frans de Jonge b8b6abe4d4
[fix] GetText: Support Arabic plurals (#5517)
Fixes <https://github.com/koreader/koreader/issues/5516>.

Cf. <https://github.com/koreader/koreader/pull/5515>.
5 years ago
Frans de Jonge 621f36b4a9
[fix] GetText: guard against empty strings in translation (#5301)
Fixes <https://github.com/koreader/koreader/issues/5293>.
5 years ago
Frans de Jonge cddca1a5b5
[fix] Remove gettext util dependency (#5270)
A simple `string.gmatch()` should do the trick here, which avoids the need for refactoring.

Fixes <https://github.com/koreader/koreader/issues/5269>.
5 years ago
Frans de Jonge 3ab51b1f85
[spec] Test all gettext codepaths & support language with no plurals (#5260) 5 years ago
Frans de Jonge 06d26ed13e [doc] gettext developer docs 5 years ago
Frans de Jonge 2c555830f9
[feat, i18n] Implement ngettext (#5257)
Fixes <https://github.com/koreader/koreader/issues/5249>.

See https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html and https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html for more information.

Usage:
```lua
local T = ffiUtil.template
local _ = require("gettext")
local N_ = _.ngettext

local items_string = T(N_("1 item", "%1 items", num_items), num_items)
```
5 years ago
Frans de Jonge 0067c8f29e
[i18n, feat] Add basic context (msgctxt) support (#5234)
References https://github.com/koreader/koreader/issues/5232

Given an entry in the PO file like the following:

```
msgctxt "systemstat"
msgid "    Total"
msgstr "Totaal"
```

It can be addressed using:

```lua
local _ = require("gettext")
local C_ = _.pgettext
C_("systemstat", "    Total")
```

This allows to distinguish between separate instances of the same string, for example "Pages" meaning "Number of pages" and "Pages" meaning "Display of pages".

Extraction of this code pattern is not yet implemented by nightswatcher. xgettext didn't yet support Lua back in 2013 when all this was first added to the program, but now it does. Therefore it might make the most sense to replace the current Python extraction script with xgettext itself.

By default it only understands gettext.pgettext(), but that can be addressed by passing some extra command line arguments, for example:

```
xgettext -l lua -c --keyword=C_:1c,2 *.lua
```
5 years ago
Martín Fernández b15c2ed0c5 [Android] misc fixes (#4478)
* use product as device model
* print android version (codename + number) + api at launch
* exit the application properly
* fix fullscreen switching (and disable it on newer android versions)
* gettext: lower log level for message: cannot open translation file
* android common settings refactor
5 years ago
anarcat 78fbc145e4 turn missing translations into a warning (#3752)
This is not fatal and can be mistaken by new users for the cause of all their problems, like I did in #2621.
6 years ago
Frans de Jonge a394e644b5 Add gettext_spec stub (#3343) 7 years ago
Frans de Jonge 9ece6408f3 [fix] gettext: die already you stupid language not found error (#3341) 7 years ago
Huang Xin a4e1a3ba5e reflect changes in koreader/android-luajit-launcher#62 (#3254) 7 years ago
Frans de Jonge 7545d38198 fix: really skip `en_US:us` in gettext.changeLang
`new_lang` isn't `en_US` but `en_US:en`

Also see https://github.com/koreader/koreader/issues/3069#issuecomment-321769322
7 years ago
Qingping Hou a1ec64b3ed chore: skip en_US in gettext.changeLang 7 years ago
Frans de Jonge 69b826781a gettext: unescape quotation mark
Fixes #2718.
7 years ago
Qingping Hou f95ad00b9e feat: add logger module & rewrite kobo suspend script in lua 7 years ago
Frans de Jonge ab442c2434 gettext: unescape \n
Fixes the problem that any msgid with \n in it wouldn't show up translated.
10 years ago
chrox 20bd14d588 automatically set language on Android 10 years ago
chrox 88061b323e strip encoding suffix in locale name like zh_CN.utf8
So that we can automatically change to language defined in
the LANGUAGE or LANG env variable.
10 years ago
Hans-Werner Hilse 6bbfae389a don't accept empty strings as valid translations 10 years ago
HW ed982d3c95 Added a pure Lua gettext implementation 10 years ago
chrox 92219a1f1e cleanup: expand tab to 4 spaces 10 years ago
HW ef111b99c6 Refactored to use strictly locals 11 years ago
Qingping Hou 31f3564158 add gettext lua module 11 years ago