Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 23 Oct 2014, 00:53
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects » Localization Project
i18n-ed Gettexted Scripts In The PET and Hardinfo.
Moderators: Lobster, MU, raffy
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Wed 16 Jan 2013, 12:16    Post subject: Hardinfo  

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.
hardinfo.patch.gz
Description  Patch to Hardinfo to add internationalization.
gz

 Download 
Filename  hardinfo.patch.gz 
Filesize  34.21 KB 
Downloaded  364 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 17 Jan 2013, 12:33    Post subject: hardinfo.pot  

hardinfo.pot uploaded to my collection of pot files Very Happy
(hardinfo compiled, translated and used, very nice) thank you
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 18 Jan 2013, 06:54    Post subject: hardinfo
Subject description: is it my bug or yours?
 

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:
LANGUAGE=en hardinfo

shows that it is correct
hardinfo.png
 Description   missing some values in translated hardinfo
hardinfo from /intrd/pup_ro2
 Filesize   39.62 KB
 Viewed   482 Time(s)

hardinfo.png

Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Fri 18 Jan 2013, 12:00    Post subject: hardinfo  

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.
capture12338.png
 Description   
 Filesize   38.92 KB
 Viewed   556 Time(s)

capture12338.png

Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 18 Jan 2013, 13:44    Post subject: hardinfo
Subject description: date.....
 

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

Fr Jan 18 18:45:25 2013 Rolling Eyes
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 18 Jan 2013, 14:02    Post subject: hardinfo
Subject description: date memory
 

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
Back to top
View user's profile Send private message 
esmourguit


Joined: 17 Nov 2006
Posts: 1288
Location: Sur l'ile aux oiseaux.

PostPosted: Sun 20 Jan 2013, 06:36    Post subject:  

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 Wink
2.png
 Description   
 Filesize   33.59 KB
 Viewed   418 Time(s)

2.png

1.png
 Description   
 Filesize   40.21 KB
 Viewed   543 Time(s)

1.png


_________________
Toutou Linux - Pets francisés
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 20 Jan 2013, 15:25    Post subject: Re: hardinfo
Subject description: uptime
 

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 Exclamation
hardinfo_uptime.png
 Description   hours and minutes translated
 Filesize   34.02 KB
 Viewed   461 Time(s)

hardinfo_uptime.png

Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Sun 20 Jan 2013, 16:33    Post subject: Uptime  

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.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Mon 21 Jan 2013, 05:13    Post subject: hardinfo
Subject description: uptime
 

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 акушер Laughing
Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Mon 21 Jan 2013, 06:53    Post subject:  Hardinfo and ngettext  

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.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Mon 21 Jan 2013, 07:08    Post subject: Re: Hardinfo and ngettext  

Very Happy
Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Mon 21 Jan 2013, 09:02    Post subject: Hardinfo new patch  

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.
hardinfo.patch.gz
Description  Re-uploaded with small fixes
gz

 Download 
Filename  hardinfo.patch.gz 
Filesize  34.56 KB 
Downloaded  401 Time(s) 

Last edited by rodin.s on Tue 22 Jan 2013, 15:43; edited 1 time in total
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Tue 22 Jan 2013, 14:35    Post subject: Re: Hardinfo new patch
Subject description: new Help
 

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 Smile

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

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
hardinfo_help.png
 Description   translated help in file /usr/share/hardinfo/doc/de/index.hlp
 Filesize   34.17 KB
 Viewed   391 Time(s)

hardinfo_help.png

Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Wed 23 Jan 2013, 08:31    Post subject: hardinfo
Subject description: about modules
 

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
hardinfo_help_about_modules.png
 Description   green underlined line is translated now
 Filesize   10.38 KB
 Viewed   385 Time(s)

hardinfo_help_about_modules.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Puppy Projects » Localization Project
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0984s ][ Queries: 13 (0.0136s) ][ GZIP on ]