Browse files

add internationalisation support

add a Make install target
  • Loading branch information...
1 parent b44bbf5 commit 64d88a1a9fd21a497087a40e7dff8b3310874420 @fenrus75 committed Dec 20, 2010
Showing with 252 additions and 20 deletions.
  1. +19 −0 Makefile
  2. +26 −0 README
  3. +16 −11 TODO
  4. +3 −0 configure
  5. +4 −3 display.cpp
  6. +1 −0 lib.h
  7. +6 −1 main.cpp
  8. +34 −0 po/Makefile
  9. +59 −0 po/nl.po
  10. +78 −0 po/powertop.pot
  11. +4 −4 process/do_process.cpp
  12. +2 −1 tuning/tuning.cpp
View
19 Makefile
@@ -26,11 +26,25 @@ LIBS += -lpthread -lncursesw -lpci -lz -lresolv
HEADERS := cpu/cpu.h
+PREFIX ?= /usr
+BINDIR = $(PREFIX)/bin
+LOCALESDIR = $(PREFIX)/share/locale
+MANDIR = $(PREFIX)/share/man/man8
+
+
clean:
rm -f *.o *~ powertop DEADJOE core.* */*.o */*~ csstoh css.h
powertop: $(OBJS) $(HEADERS)
g++ $(OBJS) $(LIBS) -o powertop
+ @(cd po/ && $(MAKE))
+
+install: powertop
+ mkdir -p ${DESTDIR}{BINDIR}
+ cp powertop ${DESTDIR}{BINDIR}
+ mkdir -p ${DESTDIR}{PREFIX}/var/cache/powertop
+ @(cd po/ && env LOCALESDIR=$(LOCALESDIR) DESTDIR=$(DESTDIR) $(MAKE) $@)
+
csstoh: csstoh.c
gcc -o csstoh csstoh.c
@@ -43,3 +57,8 @@ css.h: csstoh powertop.css
@echo " CC $<"
@[ -x /usr/bin/cppcheck ] && /usr/bin/cppcheck -q $< || :
@$(CC) $(CFLAGS) -c -o $@ $<
+
+
+uptrans:
+ @(cd po/ && env LG=$(LG) $(MAKE) $@)
+
View
26 README
@@ -0,0 +1,26 @@
+
+
+
+Building & Installing PowerTOP
+------------------------------
+
+just type
+
+ make
+ make install
+
+
+
+
+Build dependencies
+------------------
+
+PowerTOP uses C++, and expects g++ and libstdc++ to be functional
+
+in addition to that, it needs the following components:
+
+pciutils-devel
+ncurses-devel
+zlib-devel
+
+and a functional glibc/pthreads development environment
View
27 TODO
@@ -1,6 +1,21 @@
+Needed prior to alpha
+---------------------
+
+* usage documentation / readme sufficient for people to get going
* there is a filedescriptor leak!
+* pretty print estimate to only do 2 decimal places instead of 3
+* fix memory leaks
+
+
+Needed between alpha and 2.0 final
+----------------------------------
+* investigate tick_sched_timer and why it wakes up
+* find if we can do more detailed reporting about tasklet(softirq)
+ * deal with tasklets -- needs kernel patch
+* device events/sec into the process view
+* USB urbs as events/sec counter
* check various tunables (see powertop 1.x) into a tunable checklist
- basic infrastructure done
- needs porting over of all the powertop 1.x tunables:
@@ -9,17 +24,6 @@
- tv out??
- noatime
-* pretty print estimate to only do 2 decimal places instead of 3
-
-* fix memory leaks
-* device events/sec into the process view
-* USB urbs as events/sec counter
-
-* investigate tick_sched_timer and why it wakes up
-* find if we can do more detailed reporting about tasklet(softirq)
- * deal with tasklets -- needs kernel patch
-
-
postponed to 2.1
@@ -31,6 +35,7 @@ postponed to 2.1
done
----
+* internationalization!
* on NHM, cpu P state stats accumulate and don't reset at measurment time
* rescan for USB devices each measurement
* brightness calibration
View
3 configure
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo You can now type "make" to build PowerTOP
View
7 display.cpp
@@ -23,6 +23,7 @@
* Arjan van de Ven <arjan@linux.intel.com>
*/
#include "display.h"
+#include "lib.h"
#include <ncurses.h>
@@ -99,12 +100,12 @@ void show_tab(unsigned int tab)
wattrset(tab_bar, A_REVERSE);
mvwprintw(tab_bar, 0,0, "%120s", "");
- mvwprintw(tab_bar, 0,0, "PowerTOP 1.99");
+ mvwprintw(tab_bar, 0,0, "PowerTOP %s", POWERTOP_SHORT_VERSION);
bottom_line = newwin(1, 0, LINES-1, 0);
wattrset(bottom_line, A_REVERSE);
mvwprintw(bottom_line, 0,0, "%120s", "");
- mvwprintw(bottom_line, 0,0, " <ESC> Exit | ");
+ mvwprintw(bottom_line, 0,0, _(" <ESC> Exit | "));
current_tab = tab;
@@ -114,7 +115,7 @@ void show_tab(unsigned int tab)
wattrset(tab_bar, A_NORMAL);
else
wattrset(tab_bar, A_REVERSE);
- mvwprintw(tab_bar, 0, tab_pos, " %s ", tab_names[i].c_str());
+ mvwprintw(tab_bar, 0, tab_pos, " %s ", _(tab_names[i].c_str()));
tab_pos += 3 + tab_names[i].length();
}
View
1 lib.h
@@ -32,6 +32,7 @@
#define _(STRING) gettext(STRING)
#define POWERTOP_VERSION "1.99 alpha 1"
+#define POWERTOP_SHORT_VERSION "1.99"
extern int get_max_cpu(void);
View
7 main.cpp
@@ -154,6 +154,11 @@ int main(int argc, char **argv)
mkdir("/var/cache/powertop", 0600);
+ setlocale (LC_ALL, "");
+ bindtextdomain ("powertop", "/usr/share/locale");
+ textdomain ("powertop");
+
+
load_results("/var/cache/powertop/saved_results.powertop");
load_parameters("/var/cache/powertop/saved_parameters.powertop");
@@ -239,7 +244,7 @@ int main(int argc, char **argv)
}
endwin();
- printf("Leaving PowerTOP\n");
+ printf(_("Leaving PowerTOP\n"));
end_process_data();
View
34 po/Makefile
@@ -0,0 +1,34 @@
+SRC=$(wildcard *.po)
+OBJ= $(SRC:.po=.mo)
+INST= $(SRC:.po=.inst)
+
+translations: $(OBJ)
+
+%.mo: %.po
+ msgfmt -o $@ $<
+
+clean:
+ rm -f *.mo *~ powertop.pot
+
+powertop.pot: Makefile ../*.cpp ../*/*.cpp
+ xgettext -C -s -k_ -o powertop.pot ../*.cpp ../*/*.cpp ../*.h
+
+# hack to automate installation dynamicaly, without previous knowledge of
+# the po/mo file list (we fool make by pretending the need for .inst files).
+install: $(OBJ) $(INST)
+
+%.inst: %.mo
+ mkdir -p $(DESTDIR)$(LOCALESDIR)/$*/LC_MESSAGES/
+ -cp -f $< $(DESTDIR)$(LOCALESDIR)/$*/LC_MESSAGES/powertop.mo
+
+uptrans: $(LG).po powertop.pot ../*.cpp ../*/*.cpp
+
+$(LG).po: powertop.pot
+ifdef LG
+ msgmerge -U $@ $<
+ msgfmt --statistics $@
+else
+ @echo "Usage : make uptrans LG=xx # with xx = de, es, fi ..."
+ @exit 1
+endif
+
View
59 po/nl.po
@@ -0,0 +1,59 @@
+#: ../process/do_process.cpp:595
+msgid " Usage/s Events/s Category Description\n"
+msgstr ""
+
+#: ../display.cpp:108
+msgid " <ESC> Exit | "
+msgstr ""
+
+#: ../lib.cpp:92
+#, c-format
+msgid "%3.1f Ghz"
+msgstr ""
+
+#: ../lib.cpp:90
+#, c-format
+msgid "%4.2f Ghz"
+msgstr ""
+
+#: ../lib.cpp:83
+#, c-format
+msgid "%4lli Mhz"
+msgstr ""
+
+#: ../lib.cpp:85
+#, c-format
+msgid "%6lli Mhz"
+msgstr ""
+
+#: ../lib.cpp:79
+#, c-format
+msgid "%9lli"
+msgstr ""
+
+#: ../process/do_process.cpp:577
+#, c-format
+msgid ""
+"Estimated power: %5.1f Measured power: %5.1f Sum: %5.1f\n"
+"\n"
+msgstr ""
+
+#: ../main.cpp:247
+#, c-format
+msgid "Leaving PowerTOP\n"
+msgstr ""
+
+#: ../process/do_process.cpp:593
+msgid "Power est. Usage/s Events/s Category Description\n"
+msgstr ""
+
+#: ../process/do_process.cpp:584
+#, c-format
+msgid "The battery reports a discharge rate of %sW\n"
+msgstr ""
+
+#: ../cpu/cpu_core.cpp:118 ../cpu/cpu_linux.cpp:331 ../cpu/cpu_package.cpp:147
+#: ../cpu/intel_cpus.cpp:197 ../cpu/intel_cpus.cpp:415
+#, c-format
+msgid "Turbo Mode"
+msgstr ""
View
78 po/powertop.pot
@@ -0,0 +1,78 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-12-20 15:36-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../process/do_process.cpp:595
+msgid " Usage/s Events/s Category Description\n"
+msgstr ""
+
+#: ../display.cpp:108
+msgid " <ESC> Exit | "
+msgstr ""
+
+#: ../lib.cpp:92
+#, c-format
+msgid "%3.1f Ghz"
+msgstr ""
+
+#: ../lib.cpp:90
+#, c-format
+msgid "%4.2f Ghz"
+msgstr ""
+
+#: ../lib.cpp:83
+#, c-format
+msgid "%4lli Mhz"
+msgstr ""
+
+#: ../lib.cpp:85
+#, c-format
+msgid "%6lli Mhz"
+msgstr ""
+
+#: ../lib.cpp:79
+#, c-format
+msgid "%9lli"
+msgstr ""
+
+#: ../process/do_process.cpp:577
+#, c-format
+msgid ""
+"Estimated power: %5.1f Measured power: %5.1f Sum: %5.1f\n"
+"\n"
+msgstr ""
+
+#: ../main.cpp:247
+#, c-format
+msgid "Leaving PowerTOP\n"
+msgstr ""
+
+#: ../process/do_process.cpp:593
+msgid "Power est. Usage/s Events/s Category Description\n"
+msgstr ""
+
+#: ../process/do_process.cpp:584
+#, c-format
+msgid "The battery reports a discharge rate of %sW\n"
+msgstr ""
+
+#: ../cpu/cpu_core.cpp:118 ../cpu/cpu_linux.cpp:331 ../cpu/cpu_package.cpp:147
+#: ../cpu/intel_cpus.cpp:197 ../cpu/intel_cpus.cpp:415
+#, c-format
+msgid "Turbo Mode"
+msgstr ""
View
8 process/do_process.cpp
@@ -574,14 +574,14 @@ void process_update_display(void)
sum += all_power[i]->Witts();
}
- wprintw(win, "Estimated power: %5.1f Measured power: %5.1f Sum: %5.1f\n\n",
+ wprintw(win, _("Estimated power: %5.1f Measured power: %5.1f Sum: %5.1f\n\n"),
all_parameters.guessed_power, global_joules_consumed(), sum);
#endif
pw = global_joules_consumed();
if (pw > 0.0001) {
char buf[32];
- wprintw(win, "The battery reports a discharge rate of %sW\n",
+ wprintw(win, _("The battery reports a discharge rate of %sW\n"),
fmt_prefix(pw, buf));
wprintw(win, "\n");
}
@@ -590,9 +590,9 @@ void process_update_display(void)
if (show_power)
- wprintw(win, "Power est. Usage/s Events/s Category Description\n");
+ wprintw(win, _("Power est. Usage/s Events/s Category Description\n"));
else
- wprintw(win, " Usage/s Events/s Category Description\n");
+ wprintw(win, _(" Usage/s Events/s Category Description\n"));
for (i = 0; i < all_power.size(); i++) {
char power[16];
View
3 tuning/tuning.cpp
@@ -39,6 +39,7 @@
#include "ethernet.h"
#include "../display.h"
#include "../html.h"
+#include "../lib.h"
static void sort_tunables(void);
@@ -107,7 +108,7 @@ static void __tuning_update_display(int cursor_pos)
wattrset(win, A_REVERSE);
wprintw(win, ">> ");
}
- wprintw(win, "%s %s\n", res, desc);
+ wprintw(win, "%s %s\n", _(res), _(desc));
}
}

0 comments on commit 64d88a1

Please sign in to comment.