i18n-ed Gettexted Scripts In The PET and Hardinfo.

For efforts in internationalising Puppy and solving problems in this area
Message
Author
rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Hardinfo

#16 Post by rodin.s »

Hello, Barry.
I have patched source from latest git: http://ompldr.org/vaDNraQ/hardinfo.tar.gz
I do not have Wary with devx now but I've managed to compile it in Precise-5.4.2 and in Racy-5.3.90. Racy is a close relative to Wary, I guess.
The file 'hardinfo.po' in 'po' directory is for Russian. Delete it or rename as ru.po.
Attachments
hardinfo.patch.gz
Patch to Hardinfo to add internationalization.
(34.21 KiB) Downloaded 784 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo.pot

#17 Post by L18L »

hardinfo.pot uploaded to my collection of pot files :D
(hardinfo compiled, translated and used, very nice) thank you

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo

#18 Post by L18L »

Before I am going to dig deeper just one question:
Is it my bug (translating) or yours (is it OK in other languages?) ?

--

edited

It is mine!

Code: Select all

LANGUAGE=en hardinfo
shows that it is correct
Attachments
hardinfo.png
missing some values in translated hardinfo
hardinfo from /intrd/pup_ro2
(39.62 KiB) Downloaded 843 times

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

hardinfo

#19 Post by rodin.s »

As far as I remember I didn't translate these items: memory, date/time, uptime, load average. I noticed that these items are not updated when translated so I left them in English and even switched that part of code to LANG=C.
Attachments
capture12338.png
(38.92 KiB) Downloaded 1056 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo

#20 Post by L18L »

Thanks
so I will dig......
date is strange

Fr Jan 18 18:45:25 2013 :roll:

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo

#21 Post by L18L »

I have reverted to not translate date and memory
line 683 in hardinfo.po wrote:"Memory=...\n"
"Maschinentyp=%s\n"
"Betriebssystem=%s\n"
"Benutzer=%s\n"
"Date/Time=...\n"
Both of them seem to be kind of very special things,
values are permanently refreshed
that are not just messages

---
edited:
same for
"Uptime=...\n"
---
edited:
I see in modules/computer:
computer_get_formatted_uptime() :wink:

User avatar
esmourguit
Posts: 1410
Joined: Fri 17 Nov 2006, 14:45
Location: Entre l'ile aux oiseaux.et l'ile de sainte Lucie

#22 Post by esmourguit »

Bonjour à toutes et tous,

I made french hardinfo.po then .mo files, but there is a little difference between the two versions of hardinfo executables files.
The ancient (original Precise 5.4.3) hardinfo executable file displays date and time in french and no translations in french (that seems normal), but the new one (from BK blog from today january 20th) displays date and time in english, while all is in french.

And the second one recognize the Operating System...

Cordialement ;)
Attachments
2.png
(33.59 KiB) Downloaded 614 times
1.png
(40.21 KiB) Downloaded 983 times
[url=http://moulinier.net/][color=blue][b]Toutou Linux[/b][/color][/url] - [url=http://toutoulinux.free.fr/pet.php][color=blue][b]Paquets français[/b][/color][/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: hardinfo

#23 Post by L18L »

rodin.s wrote:As far as I remember I didn't translate these items: memory, date/time, uptime, load average. I noticed that these items are not updated when translated so I left them in English and even switched that part of code to LANG=C.
uptime translated :idea:

coming soon :!:
Attachments
hardinfo_uptime.png
hours and minutes translated
(34.02 KiB) Downloaded 870 times

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Uptime

#24 Post by rodin.s »

Did you add any additional gettext lines somewhere for this? I remember it was hard thing for me to do. It was a place where I should have used ngettext for correct translation but in that case it was necessary to rewrite all code in uptime.c. Also I wanted minimal changes to original code not to break something so I decided to leave it in English as well.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo

#25 Post by L18L »

It was just try and try and try.... (never learned C)

Changes were made only in modules/computer/uptime.c
Do not forget to add this file in po/POTFILES.in
modules/computer/uptime.c wrote:/*
* HardInfo - Displays System Information
* Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* TODO: done: 2012-01-21 ngettext for days, hours, minutes */

#include "hardinfo.h"
#include "computer.h"

UptimeInfo *
computer_get_uptime(void)
{
UptimeInfo *ui = g_new0(UptimeInfo, 1);
FILE *procuptime;
gulong minutes;

if ((procuptime = fopen("/proc/uptime", "r")) != NULL) {
(void)fscanf(procuptime, "%lu", &minutes);
ui->minutes = minutes / 60;
fclose(procuptime);
} else {
return NULL;
}

ui->hours = ui->minutes / 60;
ui->minutes %= 60;
ui->days = ui->hours / 24;
ui->hours %= 24;

return ui;
}

gchar *
computer_get_formatted_uptime()
{
setlocale(LC_ALL, "");

UptimeInfo *ui;
gchar *tmp;
ui = computer_get_uptime();

if (ui->days < 1) {
if (ui->hours < 1) {
tmp =
g_strdup_printf("%s",
g_strdup_printf (ngettext ("%d minute", "%d minutes", ui->minutes), ui->minutes)

);
} else {
tmp =
g_strdup_printf("%s %s",
g_strdup_printf (ngettext ("%d hour", "%d hours", ui->hours), ui->hours),
g_strdup_printf (ngettext ("%d minute", "%d minutes", ui->minutes), ui->minutes)
);
}
} else {
tmp =
g_strdup_printf("%s %s %s",
g_strdup_printf (ngettext ("%d day", "%d days", ui->days), ui->days),
g_strdup_printf (ngettext ("%d hour", "%d hours", ui->hours), ui->hours),
g_strdup_printf (ngettext ("%d minute", "%d minutes", ui->minutes), ui->minutes)
);
}

g_free(ui);

setlocale(LC_ALL, "C"); //Load Average is not updated if locale is not C, swithc locale to C

return tmp;
}
Would you like to continue using ngettext with other modules ?
It is your baby, I am just the акушер :lol:

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Hardinfo and ngettext

#26 Post by rodin.s »

Thank you, it works great. I actually used ngettext in hardinfo/util.c, but now I understand that I have made a mistake there and printf doesn't work that way. Now I see that function seconds_to_string is used in modules/devices/battery.c. It will work OK with minutes, but there will be an error with hours and days. I guess I can use your code there directly.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Hardinfo and ngettext

#27 Post by L18L »

:D

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Hardinfo new patch

#28 Post by rodin.s »

Ok, I have made a patch for Hardinfo with fixes in ngettext in util.c and added ngettext in uptime.c. I have also changed position of "LANG=C" for LoadAverage and Date/Time is now displayed in local language. I do not have a battery on my PC to test if util.c ngettext works correctly but I hope it does.
Hardinfo patched source is here.
Attachments
hardinfo.patch.gz
Re-uploaded with small fixes
(34.56 KiB) Downloaded 886 times
Last edited by rodin.s on Tue 22 Jan 2013, 19:43, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Hardinfo new patch

#29 Post by L18L »

rodin.s wrote:... I do not have a battery on my PC to test if util.c ngettext works correctly but I hope it does.
Same with me :)

Thanks for the patch (and the advice how to use it :) )

Localized Help:
my changed function in shell/callbacks.c wrote: void cb_open_online_docs()
{
Shell *shell;

shell = shell_get_main_shell();
if (shell->help_viewer) {
help_viewer_open_page(shell->help_viewer, "index.hlp");
} else {
gchar *help_dir;

help_dir = g_build_filename(params.path_data, "doc", NULL);

gchar *lang_ptr, *lang, *lang1, *lang2;
lang_ptr = getenv ("LANG");
lang = g_strdup_printf("%s", lang_ptr); /* ex: pt_BR.utf-8 */
lang2 = lang;
lang2 = strtok(lang2, "_"); /* ex: pt */

if (lang2 != "en") {
lang1 = strtok(lang, "."); /* ex: pt_BR */
help_dir = g_build_filename(help_dir, lang1, NULL);
if (!g_file_test(help_dir, G_FILE_TEST_EXISTS)) {
help_dir = g_build_filename(params.path_data, "doc", NULL);
help_dir = g_build_filename(help_dir, lang2, NULL);
if (!g_file_test(help_dir, G_FILE_TEST_EXISTS)) {
help_dir = g_build_filename(params.path_data, "doc", NULL);
}

}
}

shell->help_viewer = help_viewer_new(help_dir, "index.hlp");

g_free(help_dir);

}
}
@all
Just insert the green text
and test
Attachments
hardinfo_help.png
translated help in file /usr/share/hardinfo/doc/de/index.hlp
(34.17 KiB) Downloaded 779 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

hardinfo

#30 Post by L18L »

Found a way to change something (translation) in a static module
Example benchmarks
modules/benchmark.c wrote:ModuleAbout *hi_module_get_about(void)
{
static ModuleAbout ma[] = {
{
.author = "Leandro A. F. Pereira",
.description = "Perform tasks and compare with other systems",
.version = VERSION,
.license = "GNU GPL version 2"}
};
ma->description = _("Perform tasks and compare with other systems");
return ma;
}
Apply the equivalent for network.c devices.c and computer.c
Attachments
hardinfo_help_about_modules.png
green underlined line is translated now
(10.38 KiB) Downloaded 849 times

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Hardinfo update

#31 Post by rodin.s »

I have made some changes to Hardinfo. Now it can display distro name and version number. I have also applied ideas of L18L above. Thanks.
I have made a pet with new2dir: http://ompldr.org/vaGpvbQ/hardinfo-0.5.2pre-i486.pet
Source directory: http://ompldr.org/vaGpveA/hardinfo-i18n.tar.gz
Attachments
hardinfo.patch.gz
(35.96 KiB) Downloaded 873 times
capture8659.png
(36.31 KiB) Downloaded 1745 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Hardinfo update

#32 Post by L18L »

rodin.s wrote:I have made some changes to Hardinfo. Now it can display distro name and version number. I have also applied ideas of L18L above.. .
Thanks.

Scripting Languages
Compiler
Tools

do not translate :cry:

I have uploaded updated hardinfo.pot to PortableObjectTemplate Files

gcmartin

Benefit presented with recent HARDINFO update

#33 Post by gcmartin »

This helps community, at large. Hardinfo presents in its top 2 pages system identity information that was not present before on 32bit PUPs built with WOOF.

This is helpful when members post their system's behavior so that its known which distro & version is being presented.

In addition, the following terminal command creates a report, "PUPPY_System_Report.txt.gz"

Code: Select all

# hardinfo -r >> PUPPY_System_Report.txt.gz
when posted to forum helps those reviewing and providing assistance.

Thanks for this @Rodin.S

Hmmm?? Should Hardinfo has a dedicated thread?

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

hardinfo tranlsations fixed

#34 Post by rodin.s »

I have fixed translations of Development section. Thank you.
The pet is re-uploaded here: http://ompldr.org/vaGtkdg/hardinfo-0.5.2pre-i486.pet
Attachments
hardinfo.patch.gz
New patch to original source
(35.32 KiB) Downloaded 876 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: hardinfo tranlsations fixed

#35 Post by L18L »

One idea leads to another:

Should not exist a choice for language in generated reports to be locale OR English (sent to developer)?

@BarryK, would you like to get Arabic reports? :wink:

Post Reply