kiwix-desktop icon indicating copy to clipboard operation
kiwix-desktop copied to clipboard

Categories should not be translated in Kiwix-Desktop

Open kelson42 opened this issue 1 year ago • 19 comments

We have currently a lot of categories translation in the source code:

$ grep -ri wikivoyage .
grep: ./kiwix-desktop: binary file matches
./resources/i18n/ko.json:	"wikivoyage": "위키여행",
./resources/i18n/sk.json:	"wikivoyage": "Wikicesty",
./resources/i18n/sq.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/ta.json:	"wikivoyage": "விக்கிப்பயணம்",
./resources/i18n/eo.json:	"wikivoyage": "Vikivojaĝo",
./resources/i18n/scn.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/fa.json:	"wikivoyage": "ویکی‌سفر",
./resources/i18n/tr.json:	"wikivoyage": "Vikigezgin",
./resources/i18n/ro.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/sro.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/pt-br.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/lb.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/sr-ec.json:	"wikivoyage": "Википутовања",
./resources/i18n/ca.json:	"wikivoyage": "Viquiviatges",
./resources/i18n/sdc.json:	"wikivoyage": "Vichiviàggiu",
./resources/i18n/fi.json:	"wikivoyage": "Wikimatkat",
./resources/i18n/es.json:	"wikivoyage": "Wikiviajes",
./resources/i18n/sc.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/ja.json:	"wikivoyage": "ウィキボヤージュ",
./resources/i18n/de.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/da.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/mk.json:	"wikivoyage": "Википатување",
./resources/i18n/zgh.json:	"wikivoyage": "ⵡⵉⴽⵉⵎⵓⴷⴷⵓ",
./resources/i18n/qqq.json:	"wikivoyage": "{{Identical|Wikivoyage}}",
./resources/i18n/zh-hans.json:	"wikivoyage": "维基导游",
./resources/i18n/diq.json:	"wikivoyage": "Wikigeyroğ",
./resources/i18n/sl.json:	"wikivoyage": "Wikipotovanje",
./resources/i18n/he.json:	"wikivoyage": "ויקימסע",
./resources/i18n/en.json:    "wikivoyage":"Wikivoyage",
./resources/i18n/hy.json:	"wikivoyage": "Վիքիճամփորդ",
./resources/i18n/my.json:	"wikivoyage": "ဝီကီခရီးသွား",
./resources/i18n/bn.json:	"wikivoyage": "উইকিভ্রমণ",
./resources/i18n/sv.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/sms.json:	"wikivoyage": "Wikimääʹtǩ",
./resources/i18n/ku-latn.json:	"wikivoyage": "Wîkîger",
./resources/i18n/ms.json:	"wikivoyage": "Wikikembara",
./resources/i18n/ru.json:	"wikivoyage": "Викигид",
./resources/i18n/io.json:	"wikivoyage": "Wikivoyajo",
./resources/i18n/uk.json:	"wikivoyage": "Вікімандри",
./resources/i18n/th.json:	"wikivoyage": "วิกิท่องเที่ยว",
./resources/i18n/it.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/ar.json:	"wikivoyage": "ويكي الرحلات",
./resources/i18n/nqo.json:	"wikivoyage": "ߥߞߌߕߊ߯ߡߊߘߐߕߊ߮",
./resources/i18n/skr-arab.json:	"wikivoyage": "وکی سیرسپاٹا",
./resources/i18n/pl.json:	"wikivoyage": "Wikipodróże",
./resources/i18n/zh-hant.json:	"wikivoyage": "維基導遊",
./resources/i18n/br.json:	"wikivoyage": "Wikibeaj",
./resources/i18n/fr.json:	"wikivoyage": "Wikivoyage",
./resources/i18n/cs.json:	"wikivoyage": "Wikicesty",
./resources/i18n/nb.json:	"wikivoyage": "Wikivoyage",

Translations should be done in libkiwix and made available via the kiwix-serve/https://library.kiwix.org.

Depends on https://github.com/kiwix/libkiwix/issues/844

kelson42 avatar Aug 03 '23 16:08 kelson42

@juuz0 How does it work currently if there is not Internet? There is a default list somewhere hardcoded in the list or does the category list is dynamically built from the local library?

kelson42 avatar Aug 03 '23 16:08 kelson42

does the category list is dynamically built from the local library?

This. libkiwix returning the translation should work well

juuz0 avatar Aug 04 '23 04:08 juuz0

@juuz0 so we could remove them from kiwix-desktop? If I understand right, all the category stuff is not data-driven, and therefore kiwix-desktop retrieves the values directly from the libkiwix without any API call?

kelson42 avatar Aug 04 '23 05:08 kelson42

How does it work currently if there is not Internet?

That is a really good question. We must be sure that translations are coming from libkiwx (we have in local) and not from opds stream.

But yes, now translations should be moved from kiwix-desktop to libkiwix.

mgautierfr avatar Aug 04 '23 08:08 mgautierfr

@ShaopengLin You (should) have the primitive alrady in the libkiwix to do that. Please just use them.

kelson42 avatar Jul 19 '24 06:07 kelson42

@kelson42 I am unable to find any primitives. The getBooksCategories already get from libkiwix and they are all still using the i18n key string we have. The only thing I saw in libkiwix is in server/i18n.h (which I don't think is exportable), but the i18n translations of these i18n key strings are also not in libkiwix's static/skin/i18n. Please correct me if I am missing something obvious.

ShaopengLin avatar Jul 20 '24 05:07 ShaopengLin

@ShaopengLin Hmmm, I might be wrong then... because I just remarked that kiwix-serve categories are not translated either! Documentation is not helpful either.

@mgautierfr @veloman-yunkan Could you please guide @ShaopengLin so he can implement this issue properly? It seems that something might have to be done at libkiwix level!

kelson42 avatar Jul 20 '24 08:07 kelson42

@mgautierfr @veloman-yunkan Could you please guide @ShaopengLin so he can implement this issue properly? It seems that something might have to be done at libkiwix level!

libkiwix has all the required infrastructure (in src/server/i18n.{h,cpp}) however it is not part of its public API so we just need to expose it.

veloman-yunkan avatar Jul 22 '24 09:07 veloman-yunkan

@veloman-yunkan Thank you, should obviously not be related to the server, so not the proper ultimate code location.

kelson42 avatar Jul 22 '24 09:07 kelson42

@kelson42 Absolutely. We will move the implementation as part of kiwix/libkiwix#1103.

veloman-yunkan avatar Jul 22 '24 09:07 veloman-yunkan

@veloman-yunkan Thx! @ShaopengLin Please adapt libkiwix first, then kiwix desktop

kelson42 avatar Jul 22 '24 11:07 kelson42

@ShaopengLin All clear on your side for implementation?

kelson42 avatar Jul 27 '24 21:07 kelson42

With the slugify PR I think I am comfortable with the libkiwix structure. Can probably have a PR on libkiwix to add the i18n translation for categories and expose the API.

For Desktop If I am not mistaken, just need to replace the gt() calls with the exposed API.

ShaopengLin avatar Jul 27 '24 22:07 ShaopengLin

@ShaopengLin The whole retrieval of categories should come from the libkiwix, not only the translation.

kelson42 avatar Jul 28 '24 05:07 kelson42

That makes sense, I will adapt the filtering with the translations.

@kelson42 Just to make sure I do not make any more misconceptions: From the previous discussion, I assume all the categories need to be supported by libkiwix and OPDS retrieval of categories should be removed.

~@veloman-yunkan Does the filtering adapt with i18n, i.e. if I use the translated categories in the filters, would the local and remote filter adapt? I am not sure if I fully understand the filtering behavior so I think it is best to ask.~

ShaopengLin avatar Jul 28 '24 06:07 ShaopengLin

OPDS retrieval should not be removed, but this retrieval works only online. It should also properly work offline.

kelson42 avatar Jul 28 '24 07:07 kelson42

Ok so I believe we actually are implementing two separate things:

  1. retrieve categories from libkiwix.
  2. The translation should use libkiwix translation functions.

Previously I got the idea that we are combining the changes into one, which is we only retrieve the translated categories. This should be a quick change in libkiwix then.

ShaopengLin avatar Aug 03 '24 07:08 ShaopengLin

Also in desktop we also don't seem to be doing translations either... I already have the change ready and after libkiwix goes through my change in this one will soon.

ShaopengLin avatar Aug 03 '24 08:08 ShaopengLin

@ShaopengLin Can you please push your code now that https://github.com/kiwix/libkiwix/pull/1112 is merged?

kelson42 avatar Aug 14 '24 17:08 kelson42