domschrei / krunner-symbols

A lightweight KRunner plugin (Plasma 5) to retrieve unicode symbols, or any other string, based on a corresponding keyword.
GNU General Public License v3.0
117 stars 12 forks source link

Localization #20

Open JosephChataignon opened 3 years ago

JosephChataignon commented 3 years ago

This excellent plugin works only with the english names of symbols so far. It would be ideal if it could be used with other languages as well.

domschrei commented 3 years ago

Thanks for the suggestion! You're right, that would be ideal.

Translating the basic definitions in krunner-symbolsrc could be a little joint effort, not too difficult I guess, as we should be able to use the built-in localization features of KConfigGroups writing definitions like that:

cross[en]=✝
kreuz[de]=✝
croix[fr]=✝

This would help not to clutter the krunner suggestions with many foreign descriptions you are not interested in. Maybe the English variant should still be defined without [en] (in case the symbol is not present in the user's locale).

For the Unicode symbols, I found this nice repository belonging to the unicode-table.com website: https://github.com/unicode-table/unicode-table-data If I understand the licensing correctly, the translations can be used freely, so I could convert the data into our config format. But for performance reasons the plugin should probably programmatically find the user's locale on upstart and then only load the Unicode symbols file from that locale (or English by default). I'll look into that!

JosephChataignon commented 3 years ago

From what I understand, only the English language files follow the Unicode Terms of Use, translations are not provided by the Unicode Consortium and thus follow the repo's license, which is free. So you should be able to keep using the english versions you've been using so far, and add the translated ones on top.

domschrei commented 3 years ago

Yes, I think you are right.

I have pushed initial support for Unicode databases in other languages. The "upstream" for these translations is https://github.com/domschrei/unicode-table-data for now (forked because the original project owner does not seem to be very active regarding pull requests at the moment). Yet, some of the translations turn out to be rubbish (in German at least), so anyone is welcome to help out by creating pull requests for translation improvements.

To make use of localized Unicode definitions for French and German, execute bash get_unicode_tables.sh fr de which will fetch above Github repo and convert the respective Unicode files into a single file in KConfig format readable by krunner which will be dropped into the krunner-symbols-unicode directory. (Calling the script without any arguments converts all available locales.) Then, bash build_and_install.sh will now also install that directory into a system directory and krunner should be able to recognize the new Unicode database using your user locale. I do want to streamline this process later on, but this should be fine for some testing and trying out.

This mechanism is tied to a new user preference flag UseLocalizedUnicodeDescriptions which defaults to true right now and can be changed in your local ~/.config/krunner-symbolsrc. If false, the English version will be used.