LudovicRousseau / pcsc-tools

Some tools to be used with smart cards and PC/SC
https://pcsc-tools.apdu.fr/
GNU General Public License v2.0
185 stars 63 forks source link

Initial localization support #75

Closed Pro-pra closed 1 year ago

Pro-pra commented 1 year ago

Have nice day! I tried to add localization using libintl-perl

.pot file generated, on some string i have errors ex.: ../scriptor:47: invalid variable interpolation at "$"

Pro-pra commented 1 year ago

after add .mo file, characters in menu non-readable :( Screenshot_20230310_153313

LudovicRousseau commented 1 year ago

How do you generate the .pot file? How to you generate the .po file(s)? How to you generate the .mo file(s)?

Up to now I used a generated Makefile to call the correct "magic" commands.

LudovicRousseau commented 1 year ago

@Pro-pra I got no answer fro you. I am OK to add internationalisation and localosation. But I need your help.

Pro-pra commented 1 year ago

Hi, sorry, i forgot add Makefile to po dir it`s based on example from https://github.com/gflohr/libintl-perl/blob/master/sample/simplecal/po/Makefile

LudovicRousseau commented 1 year ago

Thanks for the Makefile. I am now able to get a French l10n of scriptor. Nice.

I get the same problem as you for Russian. It looks like the UTFè8 encoding has an issue. You can test using the branch i18n from https://github.com/LudovicRousseau/pcsc-tools-debug/tree/i18n

LudovicRousseau commented 1 year ago

I also note that I have no problem with scriptor (command line in the console) in French or Russian. But I can't correctly display French accents in gscriptor. Maybe it is a problem between Perl and Gtk+.

Pro-pra commented 1 year ago

I change https://github.com/LudovicRousseau/pcsc-tools-debug/blob/0122025c2485435ff7fc8e12faccf8303b91569b/po/Makefile#L4 to libdir = ../

Pro-pra commented 1 year ago

Add use utf8; not help me for enable utf8 support, need check docs for perl-gtk3 may be https://wiki.gnome.org/Projects/GTK-Perl/ say "unicode support already present"

LudovicRousseau commented 1 year ago

I tried adding accented letters in https://github.com/LudovicRousseau/pcsc-tools/blob/master/gscriptor#L183 and I have the problem (even without your modifications).

I need to add:

 use utf8; 

This is expected since, in this case, the script contains utf8 characters so I must indicate it to Perl.

But if I use the __() construction the text is wrong again in the Gtk interface. Even for the original English version.

If I use print(__("_File") . "\n"); I get the correct text (including accents) in the console. So the function __() works as expected.

Not idea what the problem is.

Pro-pra commented 1 year ago

hmmm.... libintl unicode support need check.... may be https://github.com/gflohr/libintl-perl/ this project have answer for this?

LudovicRousseau commented 1 year ago

I am not sure the problem is with libintl-perl. I used this patch:

diff --git a/gscriptor b/gscriptor
index b4a9db5..46a107f 100755
--- a/gscriptor
+++ b/gscriptor
@@ -205,6 +205,7 @@ sub arrange_widgets () {
         [ "About",             undef,           __("_About"),         "<control>A",        __("About"),                            \&About ],
     );

+   print __("_File") . "\n";
     my $ui = Gtk3::UIManager->new();
     my $action_group = Gtk3::ActionGroup->new('AppWindowActions');
     $action_group->add_actions( \@appActions, undef );
diff --git a/po/fr.po b/po/fr.po
index 2c2ca28..52ca83b 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -18,7 +18,7 @@ msgstr ""

 #: ../gscriptor:188
 msgid "_File"
-msgstr ""
+msgstr "Fichier àç"

 #: ../gscriptor:189
 msgid "_New"

And I correctly get the output Fichier àç in the console. So the function __() works as expected.

With LANG=ru_RU.UTF-8 I get i the console _Файл.

Pro-pra commented 1 year ago

work in console not work in gtk3 window hmmm....

Pro-pra commented 1 year ago

Please check this info https://metacpan.org/dist/libintl-perl/view/lib/Locale/libintlFAQ.pod#Why-do-non-ASCII-characters-in-my-Gtk2-application-look-messed-up

LudovicRousseau commented 1 year ago

It works now. I updated my i18n branch at https://github.com/LudovicRousseau/pcsc-tools-debug/commits/i18n

The next step: how/where to install the .mo files so that perl can find them automatically?

Pro-pra commented 1 year ago

Cool!!!

XDG standard path: ex. /usr/share/locale/ru/LC_MESSAGES/pcsc-tools.mo

may be "make install" from ./po directory install all locales to right path?

LudovicRousseau commented 1 year ago

Not sure about this path.

It looks like Perl is looking for a LocaleData directory in these places:

I am not sure which one to use. On my Debian system none of them exist already.

Pro-pra commented 1 year ago

i put locale to /usr/share/locale/ru/LC_MESSAGES and its works fine.

libintl and gettext and msgfmt utils work with /usr/share/locale/*

LudovicRousseau commented 1 year ago

I updated https://github.com/LudovicRousseau/pcsc-tools-debug/tree/i18n

Now you can use the classic:

./configure
make
sudo make install

Please test on your side and tell me if it works (or not) for you.

Pro-pra commented 1 year ago
$ LANG=C make -f Makefile.intl update-po
cat: /POTFILES: No such file or directory
make pcsc-tools.pot
make[1]: Entering directory '/home/rosa/tmp/pcsc-tools-debug-i18n/po'
make[1]: Nothing to be done for 'pcsc-tools.pot'.
make[1]: Leaving directory '/home/rosa/tmp/pcsc-tools-debug-i18n/po'
cd ; \
        catalogs='ru fr'; \
        for cat in $catalogs; do \
          cat=`basename $cat`; \
          lang=`echo $cat | sed 's/\.po$//'`; \
          mv $lang.po $lang.old.po; \
          echo "$lang:"; \
          if msgmerge $lang.old.po pcsc-tools.pot -o $lang.po; then \
            rm -f $lang.old.po; \
          else \
            echo "msgmerge for $cat failed!"; \
            rm -f $lang.po; \
            mv $lang.old.po $lang.po; \
          fi; \
        done
mv: cannot stat 'ru.po': No such file or directory
ru:
msgmerge: error while opening "ru.old.po" for reading: No such file or directory
msgmerge for ru failed!
mv: cannot stat 'ru.old.po': No such file or directory
mv: cannot stat 'fr.po': No such file or directory
fr:
msgmerge: error while opening "fr.old.po" for reading: No such file or directory
msgmerge for fr failed!
mv: cannot stat 'fr.old.po': No such file or directory
make: *** [Makefile.intl:79: update-po] Error 1

$(srcdir) needed

LudovicRousseau commented 1 year ago

I pushed a new commit. You need to first run ./bootstrap at least once. Then ./configure.

Pro-pra commented 1 year ago

may be need more simple way for work with translations? i need "make update-po" and not need compile programm for this.

LudovicRousseau commented 1 year ago

We can discuss about complexity if you want.

My question was: do you get the Russian translation after the commands:

./configure
make
sudo make install
Pro-pra commented 1 year ago

Yes, work good. see screenshot: Screenshot_20230403_111906

Some messages untranslated: scriptor --help see therminal screen Wrap lines Run Script Result Welcome to the gscriptor application!

Pro-pra commented 1 year ago

also we have icons pack for desktop file: icons.tar.gz and add to desktop file: Icon=gscriptor

LudovicRousseau commented 1 year ago

Under what license do you provide the icon?

Pro-pra commented 1 year ago

GPL, we use this icons from 2019 year.

LudovicRousseau commented 1 year ago

Icon added. I also i18n more strings. Please update the ru.po file.

Pro-pra commented 1 year ago

I have error:

$ gscriptor
String found where operator expected at /usr/bin/gscriptor line 255, near "# The ""
        (Missing semicolon on previous line?)
String found where operator expected at /usr/bin/gscriptor line 255, near "my $txtReader = Gtk3::Label->new (__(""
        (Missing semicolon on previous line?)
Pro-pra commented 1 year ago

May be you add this localization patch for desktop file? (fr localization also needed)

--- pcsc-tools-1.5.4/gscriptor.desktop  2016-03-20 01:36:46.000000000 +0300
+++ pcsc-tools-1.5.4_patched/gscriptor.desktop  2019-11-12 10:28:22.470791937 +0300
@@ -1,7 +1,9 @@
 [Desktop Entry]
 Name=Gscriptor
 Comment=Send commands to smart cards
+Comment[ru]=Отправка команд на смарт-карты
 Exec=gscriptor
LudovicRousseau commented 1 year ago

gscriptor problem fixed. Sorry.

I also added l10n for the .desktop file. Where can I see the Comment field displayed?

Pro-pra commented 1 year ago

if icons now in /usr/share/icons need set Icons=pcsc-tools in pcsc-tools.desktop.in

Commend field display fine. Screenshot gscriptor with ru lang attached. Screenshot_20230410_201050

Pro-pra commented 1 year ago

I think this is good work, and need new release.

LudovicRousseau commented 1 year ago

if icons now in /usr/share/icons need set Icons=pcsc-tools in pcsc-tools.desktop.in

There is no pcsc-tools.desktop.in file. Icon= is already in https://github.com/LudovicRousseau/pcsc-tools-debug/blob/i18n/gscriptor.desktop.in#L11

I don't understand what you are talking about here.

Yes, a new release is planned. I am waiting for your "go".

Pro-pra commented 1 year ago

sorry, gscriptor.desktop.in

if icons now in /usr/share/icons need set Icon=gscriptor

Yes, a new release is planned. I am waiting for your "go".

see my screenshot, field Script and Result untranslated, button "Run" and "wrap lines" its not critical and may be translated after release

LudovicRousseau commented 1 year ago

New i18n strings. Please provide an updated ru.po file.

What do you use gscriptor for? since how long?

Pro-pra commented 1 year ago

ru.po.gz

Updated ru.po attached.

What do you use gscriptor for? since how long?

They gave me a PC with a Baikal processor. It comes with a keyboard with a built-in smart card reader.

pcsc-tools is included with many distributions.

See, looks fine! Screenshot_20230412_191026

LudovicRousseau commented 1 year ago

ru.po updated. Thanks.

I understand that you have a smart card reader. My questions are:

Pro-pra commented 1 year ago

why do you use gscriptor?

AltLinux Workstation 10.1 have it in-box. AltLinux Workstation installed to PC with Baikal.

what do you use your smart card for?

I don't have writable smart cards yet. We just read the currently existing smart cards for testing.

why not another program?

I don't know about them.

what do you like in gscriptor?

I'm the maintainer of the Rosa linux distribution, I package a lot of software and help developers make software easy to install.

LudovicRousseau commented 1 year ago

I merged the code. Thanks

The next step is to make a new release of pcsc-tools.