Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 08-12-2026, 03:15 AM   #1321
AeroFengBlade
Junior Member
AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.
 
Posts: 10
Karma: 87422
Join Date: Sep 2012
Device: Kobo Libra
Could I request a patch for enabling the "Japanese" dictionary lookup functionality for Chinese dictionaries? (basically enabling DictionaryParser::htmlForWordJapanese() for not only Japanese, but also Chinese)

I'm using a custom Chinese-English dictionary, but I have to masquerade it as a Japanese-English dictionary by renaming it dicthtml-ja-en.zip. (Advice from this thread, thanks tshering for all the pointers).

The issue is that I also want a Japanese-English dictionary. I know I can workaround by masquerading them as ja-es or ja-it dictionaries, but I think it's possible to make a patch to support both ja-en and zh-en dictionaries.

I read through the code and docs for dictutil. From my understanding:
- For English and other languages: uses 2-character prefixes, calls DictionaryParser::htmlForWordNonJapanese()
- For Japanese: uses 1-character prefixes DictionaryParser::htmlForWordJapanese(). Chinese should also use this since they both use kanji/hanzi; however, this code path is hardcoded for only the 'ja' locale.

I poked around in libnickel.so using objdump/nm (with some assistance from an LLM), and I think it all boils down to the hardcoded check in DictionaryProvider::getDefinition():
Code:
// Reconstructed code from disassembled thumb code
QString locale = dictionary.leftLanguage();
bool useJapanesePath = (locale == QLatin1String("ja"));
htmlForWord(word, useJapanesePath); // branches on htmlForWordJapanese() vs htmlForWordNonJapanese()
So far, that's about all I can verify by myself, but I think changing the code to also check for "zh" should basically do what I want.

I asked my LLM to take a look at my libnickel.so and draft a patch for kobopatch (Kobo Libra Colour, FW 4.45.23697). However there's a high potential it could be hallucinating since I don't have the proper ARM assembly knowledge to verify anything and I'm too scared to apply it.

Maybe someone here with more expertise could take a look at this to see if it holds water?

Spoiler:

Code:
# Technical details:
#   In DictionaryProvider::getDefinition(), the original code does:
#     QString locale = dictionary.leftLanguage();
#     bool useJapanesePath = (locale == QLatin1String("ja"));
#     htmlForWord(word, useJapanesePath);
#
#   The comparison is done by calling QString::operator==(QLatin1String) with a
#   hardcoded "ja" string. We replace the entire QLatin1String setup + comparison
#   call (20 bytes) with an inline check of the first UTF-16 character of the locale
#   string via Qt5's QString internal layout:
#
#     QArrayData* d = locale.d;
#     QChar firstChar = *((QChar*)((char*)d + d->offset));
#     bool useJapanesePath = (firstChar == 'j' || firstChar == 'z');
#
#   This matches "ja" (Japanese) and "zh" (Chinese) while not matching "en", "fr", etc.
#
# Assembled Thumb-2 replacement (20 bytes):
#   ldr  r0, [r5]         @ r0 = QString d-pointer
#   ldr  r3, [r0, #12]    @ r3 = d->offset (QArrayData layout)
#   add  r0, r3           @ r0 = pointer to UTF-16 char data
#   ldrh r0, [r0]         @ r0 = first UTF-16 character
#   cmp  r0, #0x6a        @ compare to 'j'
#   beq  +6               @ match -> skip to result (r0 = nonzero = true)
#   cmp  r0, #0x7a        @ compare to 'z'
#   beq  +2               @ match -> skip to result (r0 = nonzero = true)
#   movs r0, #0           @ no match -> r0 = 0 = false
#   nop                   @ padding
#   ; falls through to existing: mov r9, r0 (unchanged, saves result)

Enable Chinese dictionary fast lookup:
  - Enabled: no
  - Description: |
      Enables the fast 1-character prefix dictionary lookup for Chinese (zh) dictionaries.
      Without this patch, Chinese dictionaries using 1-char prefixes must be disguised as
      Japanese (dicthtml-ja-en.zip). With this patch, dicthtml-zh-en.zip works natively
      with fast lookup when the dictionary is built with 1-character prefixes.
  # Replace the QLatin1String("ja") setup + QString::operator== call with an inline
  # first-character check that matches both 'j' (Japanese) and 'z' (Chinese).
  - ReplaceBytes:
      Base: "DictionaryProvider::getDefinition(QString const&)"
      Offset: 28
      FindH: 2B 4B 02 22 BA 60 28 46 7B 44 FB 60 94 E8 06 00 83 F7 76 E3
      ReplaceH: 28 68 C3 68 18 44 00 88 6A 28 03 D0 7A 28 01 D0 00 20 00 BF
AeroFengBlade is offline   Reply With Quote
Old 08-13-2026, 01:38 PM   #1322
geek1011
Wizard
geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.
 
Posts: 2,838
Karma: 7454317
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD, Clara BW, Libra Colour
You should be good to try it, the worst that'll happen in this case is a crash when you use the dictionary. The logic looks sane, but I didn't actually look at the instructions surrounding it, so I can't tell you if it'll work.
geek1011 is offline   Reply With Quote
Old 08-14-2026, 10:16 AM   #1323
AeroFengBlade
Junior Member
AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.
 
Posts: 10
Karma: 87422
Join Date: Sep 2012
Device: Kobo Libra
Thanks for the reassurance, I just applied the patch on 4.45.23697 on my Libra Colour, works like a charm! I'm using the Chinese-English dictionaries I generated which I posted here. I kept the name as dicthtml-zh-en.zip and it works blazingly fast since it is using Japanese kanji lookup logic.

By the way, I was playing with your libnickel dictword-test tool, and I realized the function signatures and symbol names have changed since 2020. It looks Rakuten did some refactoring for the dictionary lookup logic, so the non-Japanese vs Japanese lookup is just a simple boolean flag passed to DictionaryParser::htmlForWord(QString const&, bool), so Japanese lookup is trivial to implement now. I submitted a PR here: https://github.com/pgaskin/kobo-mods/pull/8
AeroFengBlade is offline   Reply With Quote
Old 08-16-2026, 09:01 PM   #1324
AeroFengBlade
Junior Member
AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.AeroFengBlade knows better than to ask about the Gravitic Imploder Lance.
 
Posts: 10
Karma: 87422
Join Date: Sep 2012
Device: Kobo Libra
Never mind, I don't think this patch is necessary anymore. I came across information about the prefix_exceptions trie file in your mobileread thread and the dictutil github thread, and was able to build an index of Chinese word -> single-char hanzi prefixes (no variants needed).

This skips the Japanese lookup path completely, but still works and is pretty fast.
AeroFengBlade is offline   Reply With Quote
Old Yesterday, 12:50 PM   #1325
niclake
Junior Member
niclake began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Aug 2026
Device: Kobo Clara Colour
I have a very nitpicky patch request - the ability to show the <page> of <totalPages> AND percentage in the footer at the same time.

I know that I could turn on the progress indicator bar and get some of that, but it's just a preferred option I would love to see. I'm sure others would utilize it to a degree as well.
niclake is offline   Reply With Quote
Old Today, 01:12 AM   #1326
bluepeter
Addict
bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.bluepeter ought to be getting tired of karma fortunes by now.
 
Posts: 336
Karma: 1028630
Join Date: May 2024
Location: Salisbury, UK
Device: Assorted Kobo, Boox, PocketBook & Kindle readers
Quote:
Originally Posted by niclake View Post
I have a very nitpicky patch request - the ability to show the <page> of <totalPages> AND percentage in the footer at the same time.

I know that I could turn on the progress indicator bar and get some of that, but it's just a preferred option I would love to see. I'm sure others would utilize it to a degree as well.
Yes, that would be nice to have.

As it happens, I have both visible in my status bar when I use KOReader.
bluepeter is offline   Reply With Quote
Old Today, 10:44 AM   #1327
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 328
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by niclake View Post
I have a very nitpicky patch request - the ability to show the <page> of <totalPages> AND percentage in the footer at the same time.

I know that I could turn on the progress indicator bar and get some of that, but it's just a preferred option I would love to see. I'm sure others would utilize it to a degree as well.
Check out the (poorly named) Kobo Tweaks extension. I'm finding it to be a more stable and more flexible replacement for NickelClock on my Libra 2.

If you go to the GitHub page linked above, you will see that their example footer has the book title, page number*, percent read, AND time remaining as the left footer, and battery and clock as the right footer. And you aren't forced to have the kitty in the folded bookmark image. I also like that it can hide the battery until it drops to a certain percentage (I have it at 20%).

* page number is displayed as 4/312, not 4 of 312. There's a request on the GitHub to offer "of" display.

Last edited by fogice; Today at 04:38 PM.
fogice is offline   Reply With Quote
Old Today, 01:36 PM   #1328
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 84,568
Karma: 153744815
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by fogice View Post
Check out the (poorly named) Kobo Tweaks extension. I'm finding it to be a more stable and more flexible replacement for NickelClock on my Libra 2.

If you go to the GitHub page linked above, you will see that their example footer has the book title, page number, percent read, AND time remaining as the left footer, and battery and clock as the right footer. And you aren't forced to have the kitty in the folded bookmark image. I also like that it can hide the battery until it drops to a certain percentage (I have it at 20%).
That's a rather good find.
JSWolf is online now   Reply With Quote
Old Today, 04:36 PM   #1329
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 328
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by JSWolf View Post
That's a rather good find.
I don't think the creator has posted on MobileRead; but, it's a hard name to search for...
fogice is offline   Reply With Quote
Reply

Tags
kobopatch, patches, patching, request, requests


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Request for PW3 kernel [posted in another thread] mustdie Kindle Developer's Corner 5 10-21-2015 04:28 PM
Kobobooks.com future feature request thread Mrs_Often Kobo Reader 47 11-08-2012 11:59 AM
[Old Thread] Calibre 'feature request' thread Waba Calibre 2 02-10-2010 07:52 PM
Feature request thread? Dahak Calibre 1 08-02-2009 12:51 AM
3rd party software request thread Adam B. iRex 23 11-28-2008 01:08 PM


All times are GMT -4. The time now is 07:40 PM.


MobileRead.com is a privately owned, operated and funded community.