Skip to content

Commit

Permalink
beginning work on localisation
Browse files Browse the repository at this point in the history
git-svn-id: http://ezix.org/source/packages/lshw/development@2124 811e2811-9fd9-0310-a116-b6e8ac943c8b
  • Loading branch information
lyonel committed Oct 6, 2009
1 parent e3f4921 commit 792eba3
Show file tree
Hide file tree
Showing 9 changed files with 642 additions and 57 deletions.
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ core:
$(PACKAGENAME): core $(PACKAGENAME).o
$(CXX) $(LDFLAGS) -o $@ $(PACKAGENAME).o $(LIBS)

.PHONY: po
po:
+make -C po all

.PHONY: gui
gui: core
+make -C gui all
Expand Down
12 changes: 12 additions & 0 deletions src/core/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_

#ifdef NONLS
#define _(String) (String)
#define N_(String) String
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)
#else
#include <libintl.h>
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
#endif

#ifndef PACKAGE
#define PACKAGE "lshw"
#endif
Expand Down
27 changes: 14 additions & 13 deletions src/core/hw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hw.h"
#include "osutils.h"
#include "version.h"
#include "config.h"
#include "options.h"
#include "heuristics.h"
#include <cstring>
Expand Down Expand Up @@ -1611,7 +1612,7 @@ string hwNode::asXML(unsigned level)
struct utsname un;

out << "<?xml version=\"1.0\" standalone=\"yes\" ?>" << endl;
out << "<!-- generated by lshw-" << getpackageversion() << " -->" <<
out << _("<!-- generated by lshw-") << getpackageversion() << " -->" <<
#if defined(__GNUC__) && defined(__VERSION__)
endl << "<!-- GCC " << escapecomment(__VERSION__) << " -->" <<
#endif
Expand All @@ -1626,7 +1627,7 @@ string hwNode::asXML(unsigned level)
out << "<!-- GNU libc " << __GLIBC__ << " (" << escapecomment(version) << ") -->" << endl;
#endif
if (geteuid() != 0)
out << "<!-- WARNING: not running as root -->" << endl;
out << _("<!-- WARNING: not running as root -->") << endl;
}

if(visible(getClassName()))
Expand Down Expand Up @@ -2098,34 +2099,34 @@ string resource::asString(const string & separator) const
switch (This->type)
{
case hw::none:
result = "(none)";
result = _("(none)");
break;
case hw::dma:
result = "dma" + separator;
result = _("dma") + separator;
snprintf(buffer, sizeof(buffer), "%d", This->ui1);
break;
case hw::irq:
result = "irq" + separator;
result = _("irq") + separator;
snprintf(buffer, sizeof(buffer), "%d", This->ui1);
break;
case hw::iomem:
result = "iomemory" + separator;
result = _("iomemory") + separator;
snprintf(buffer, sizeof(buffer), "%llx-%llx", This->ull1, This->ull2);
break;
case hw::mem:
result = "memory" + separator;
result = _("memory") + separator;
snprintf(buffer, sizeof(buffer), "%llx-%llx", This->ull1, This->ull2);
if(This->b) strcat(buffer, "(prefetchable)");
if(This->b) strcat(buffer, _("(prefetchable)"));
break;
case hw::ioport:
result = "ioport" + separator;
result = _("ioport") + separator;
if(This->ul1 == This->ul2)
snprintf(buffer, sizeof(buffer), "%lx", This->ul1);
else
snprintf(buffer, sizeof(buffer), "%lx(size=%ld)", This->ul1, This->ul2 - This->ul1 + 1);
snprintf(buffer, sizeof(buffer), _("%lx(size=%ld)"), This->ul1, This->ul2 - This->ul1 + 1);
break;
default:
result = "(unknown)";
result = _("(unknown)");
}

return result + string(buffer);
Expand Down Expand Up @@ -2295,9 +2296,9 @@ string value::asString() const
case hw::text:
return This->s;
case hw::boolean:
return This->b?"true":"false";
return This->b?_("true"):_("false");
case hw::nil:
return "(nil)";
return _("(nil)");
};

return "";
Expand Down
3 changes: 2 additions & 1 deletion src/core/pci.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "version.h"
#include "config.h"
#include "pci.h"
#include "osutils.h"
#include "options.h"
Expand Down Expand Up @@ -721,7 +722,7 @@ static bool scan_capabilities(hwNode & n, struct pci_dev &d)
n.addCapability("agp8x", "AGP 8x");
break;
case PCI_CAP_ID_EXP:
n.addCapability("pciexpress", "PCI Express");
n.addCapability("pciexpress", _("PCI Express"));
break;
case PCI_CAP_ID_MSIX:
n.addCapability("msix", "MSI-X");
Expand Down
45 changes: 23 additions & 22 deletions src/core/print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "options.h"
#include "version.h"
#include "osutils.h"
#include "config.h"
#include <cstring>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -139,9 +140,9 @@ int level)
else
{
if (node.disabled())
cout << " DISABLED";
cout << _(" DISABLED");
if (!node.claimed())
cout << " UNCLAIMED";
cout << _(" UNCLAIMED");
}
if (html)
cout << "</td></tr></thead>";
Expand Down Expand Up @@ -171,7 +172,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "description: ";
cout << _("description: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getDescription();
Expand All @@ -185,7 +186,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "product: ";
cout << _("product: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getProduct();
Expand All @@ -199,7 +200,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "vendor: ";
cout << _("vendor: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getVendor();
Expand All @@ -213,7 +214,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "physical id: ";
cout << _("physical id: ");
if (html)
cout << "</td><td class=\"second\"><div class=\"id\">";
cout << node.getPhysId();
Expand All @@ -227,7 +228,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "bus info: ";
cout << _("bus info: ");
if (html)
cout << "</td><td class=\"second\"><div class=\"id\">";
cout << node.getBusInfo();
Expand All @@ -245,7 +246,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "logical name: ";
cout << _("logical name: ");
if (html)
cout << "</td><td class=\"second\"><div class=\"id\">";
cout << logicalnames[i];
Expand All @@ -260,7 +261,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "version: ";
cout << _("version: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getVersion();
Expand All @@ -274,7 +275,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "serial: ";
cout << _("serial: ");
if (html)
cout << "</td><td class=\"second\">";
cout << (enabled("output:sanitize")?REMOVED:node.getSerial());
Expand All @@ -288,7 +289,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "slot: ";
cout << _("slot: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getSlot();
Expand All @@ -302,7 +303,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "size: ";
cout << _("size: ");
if (html)
cout << "</td><td class=\"second\">";
switch (node.getClass())
Expand Down Expand Up @@ -356,7 +357,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "capacity: ";
cout << _("capacity: ");
if (html)
cout << "</td><td class=\"second\">";
switch (node.getClass())
Expand Down Expand Up @@ -412,10 +413,10 @@ int level)
if (html)
cout << "<tr><td class=\"first\">";
if (node.getSize() == 0)
cout << "address: " << hex << setfill('0') << setw(8) << node.
cout << _("address: ") << hex << setfill('0') << setw(8) << node.
getStart() << dec;
else
cout << "range: " << hex << setfill('0') << setw(8) << node.
cout << _("range: ") << hex << setfill('0') << setw(8) << node.
getStart() << " - " << hex << setfill('0') << setw(8) << node.
getStart() + node.getSize() - 1 << dec;
cout << endl;
Expand All @@ -426,7 +427,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "width: ";
cout << _("width: ");
if (html)
cout << "</td><td class=\"second\">";
cout << node.getWidth() << " bits";
Expand All @@ -440,7 +441,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "clock: ";
cout << _("clock: ");
if (html)
cout << "</td><td class=\"second\">";
cout << decimalkilos(node.getClock());
Expand All @@ -457,7 +458,7 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "capabilities: ";
cout << _("capabilities: ");
if (html)
{
vector < string > capabilities = node.getCapabilitiesList();
Expand All @@ -478,9 +479,9 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "configuration:";
cout << _("configuration:");
if (html)
cout << "</td><td class=\"second\"><table summary=\"configuration of " << node.
cout << "</td><td class=\"second\"><table summary=\"" << _("configuration of ") << node.
getId() << "\">";
for (unsigned int i = 0; i < config.size(); i++)
{
Expand All @@ -500,9 +501,9 @@ int level)
tab(level + 1, false);
if (html)
cout << "<tr><td class=\"first\">";
cout << "resources:";
cout << _("resources:");
if (html)
cout << "</td><td class=\"second\"><table summary=\"resources of " << node.
cout << "</td><td class=\"second\"><table summary=\"" << _("resources of ") << node.
getId() << "\">";
for (unsigned int i = 0; i < resources.size(); i++)
{
Expand Down
42 changes: 21 additions & 21 deletions src/lshw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ __ID("@(#) $Id$");
void usage(const char *progname)
{
fprintf(stderr, "Hardware Lister (lshw) - %s\n", getpackageversion());
fprintf(stderr, "usage: %s [-format] [-options ...]\n", progname);
fprintf(stderr, " %s -version\n", progname);
fprintf(stderr, _("usage: %s [-format] [-options ...]\n"), progname);
fprintf(stderr, _(" %s -version\n"), progname);
fprintf(stderr, "\n");
fprintf(stderr, "\t-version print program version (%s)\n", getpackageversion());
fprintf(stderr, "\nformat can be\n");
fprintf(stderr, "\t-html output hardware tree as HTML\n");
fprintf(stderr, "\t-xml output hardware tree as XML\n");
fprintf(stderr, "\t-short output hardware paths\n");
fprintf(stderr, "\t-businfo output bus information\n");
fprintf(stderr, _("\t-version print program version (%s)\n"), getpackageversion());
fprintf(stderr, _("\nformat can be\n"));
fprintf(stderr, _("\t-html output hardware tree as HTML\n"));
fprintf(stderr, _("\t-xml output hardware tree as XML\n"));
fprintf(stderr, _("\t-short output hardware paths\n"));
fprintf(stderr, _("\t-businfo output bus information\n"));
if(getenv("DISPLAY") && exists(SBINDIR"/gtk-lshw"))
fprintf(stderr, "\t-X use graphical interface\n");
fprintf(stderr, "\noptions can be\n");
fprintf(stderr, _("\t-X use graphical interface\n"));
fprintf(stderr, _("\noptions can be\n"));
fprintf(stderr,
"\t-class CLASS only show a certain class of hardware\n");
fprintf(stderr, "\t-C CLASS same as '-class CLASS'\n");
fprintf(stderr, "\t-c CLASS same as '-class CLASS'\n");
_("\t-class CLASS only show a certain class of hardware\n"));
fprintf(stderr, _("\t-C CLASS same as '-class CLASS'\n"));
fprintf(stderr, _("\t-c CLASS same as '-class CLASS'\n"));
fprintf(stderr,
"\t-disable TEST disable a test (like pci, isapnp, cpuid, etc. )\n");
_("\t-disable TEST disable a test (like pci, isapnp, cpuid, etc. )\n"));
fprintf(stderr,
"\t-enable TEST enable a test (like pci, isapnp, cpuid, etc. )\n");
fprintf(stderr, "\t-quiet don't display status\n");
fprintf(stderr, "\t-sanitize sanitize output (remove sensitive information like serial numbers, etc.)\n");
fprintf(stderr, "\t-numeric output numeric IDs (for PCI, USB, etc.)\n");
_("\t-enable TEST enable a test (like pci, isapnp, cpuid, etc. )\n"));
fprintf(stderr, _("\t-quiet don't display status\n"));
fprintf(stderr, _("\t-sanitize sanitize output (remove sensitive information like serial numbers, etc.)\n"));
fprintf(stderr, _("\t-numeric output numeric IDs (for PCI, USB, etc.)\n"));
fprintf(stderr, "\n");
}

Expand Down Expand Up @@ -104,7 +104,7 @@ char **argv)
if(latest)
{
if(strcmp(latest, getpackageversion()) != 0)
fprintf(stderr, "the latest version is %s\n", latest);
fprintf(stderr, _("the latest version is %s\n"), latest);
}
exit(0);
}
Expand Down Expand Up @@ -200,7 +200,7 @@ char **argv)

if (geteuid() != 0)
{
fprintf(stderr, "WARNING: you should run this program as super-user.\n");
fprintf(stderr, _("WARNING: you should run this program as super-user.\n"));
}

{
Expand Down Expand Up @@ -228,7 +228,7 @@ char **argv)

if (geteuid() != 0)
{
fprintf(stderr, "WARNING: output may be incomplete or inaccurate, you should run this program as super-user.\n");
fprintf(stderr, _("WARNING: output may be incomplete or inaccurate, you should run this program as super-user.\n"));
}

return 0;
Expand Down

0 comments on commit 792eba3

Please sign in to comment.