diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c11a27d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/po/messages.po diff --git a/defaults.h b/defaults.h index 3c661d6..dbcffad 100644 --- a/defaults.h +++ b/defaults.h @@ -7,12 +7,6 @@ \* information on how to configure this option. */ char DEFAULT_BANNER_FORMAT[]= S_("#O Version #V, Compiled #C\n#N #M #X #T #P, #R RAM, #B\n#H\n"); char DEFAULT_CLASSIC_FORMAT[]= S_("#O Version #V\nCompiled #C\n#N #M #X #T #P, #R RAM\n#B\n#H\n"); -/* Plural. With the coming of i18n you really can't assume plurals can */ -/* be made by adding a string to the end. Hopefully this can fix it for*/ -/* most languages. If they require significant word-order changes then */ -/* we'll have even more problems */ -char PROCESSOR_SINGULAR[]= S_("Processor"); -char PROCESSOR_PLURAL[]= S_("Processors"); /* This option picks the default mode of the linux_logo program. *\ \* If a 1 is picked, banner mode will be the default mode. */ diff --git a/linux_logo.c b/linux_logo.c index b166180..e55bb4e 100644 --- a/linux_logo.c +++ b/linux_logo.c @@ -31,6 +31,10 @@ #define _(String) gettext((String)) #else #define _(String) (String) +static const char *ngettext(const char *__msgid1, const char *__msgid2, + unsigned long int __n) { + return __n == 1 ? __msgid1:__msgid2; +} #endif /* Change the values in the below file to alter default behavior */ @@ -385,17 +389,11 @@ static int generate_sysinfo( case 'O': vmw_strcat(temp_line,os_info.os_name, BUFSIZ-strlen(temp_line)); break; - /* #P prints "Processor" or its plural. Sort of a hack */ - /* This probably doesn't work with all languages */ - case 'P': if (cpu_info.num_cpus!=1) { - vmw_strcat(temp_line,_(PROCESSOR_PLURAL), - BUFSIZ-strlen(temp_line)); - } - else { - vmw_strcat(temp_line,_(PROCESSOR_SINGULAR), - BUFSIZ-strlen(temp_line)); - } - break; + /* #P prints "Processor" or its plural */ + case 'P': vmw_strcat(temp_line, + ngettext("Processor","Processors",cpu_info.num_cpus), + BUFSIZ-strlen(temp_line)); + break; /* #R prints the amount of memory */ case 'R': mem_size=get_mem_size(); diff --git a/po/Makefile b/po/Makefile index ce732f9..440ca13 100644 --- a/po/Makefile +++ b/po/Makefile @@ -1,40 +1,35 @@ include ../Makefile.default PACKAGE=linux_logo -INSTALL_LOCALEPATH=$(PREFIX)/share/locale +INSTALL_LOCALEPATH=$(DESTDIR)$(PREFIX)/share/locale -CATALOGS = da.mo de.mo es.mo fr.mo nb.mo nl.mo it.mo pl.mo pt_BR.mo ru.mo sv.mo uk.mo zh_TW.mo +PO_FILES = $(wildcard *.po) +LINGUAS = $(basename $(PO_FILES)) +CATALOGS = $(addsuffix .mo,$(LINGUAS)) POTFILES= ../*.c ../*.h -all: $(PACKAGE).pot $(CATALOGS) +all: $(CATALOGS) $(PACKAGE).pot: $(POTFILES) - $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments --keyword=_ --keyword=S_ $(POTFILES); - if cmp -s $(PACKAGE).po $(PACKAGE).pot; then \ - rm -f $(PACKAGE).po; \ - else \ - mv $(PACKAGE).po $(PACKAGE).pot; \ - fi + $(XGETTEXT) --output=$@ --default-domain=$(PACKAGE) --add-comments --keyword=_ --keyword=S_ $^ clean: rm -f *mo *~ *.bac install: $(CATALOGS) - for n in $(CATALOGS); do \ - l=`basename $$n .mo`; \ + for l in $(LINGUAS); do \ $(INSTALL) -c -m 755 -d $(INSTALL_LOCALEPATH)/$$l; \ $(INSTALL) -c -m 755 -d $(INSTALL_LOCALEPATH)/$$l/LC_MESSAGES; \ - $(INSTALL) -c -m 644 $$n $(INSTALL_LOCALEPATH)/$$l/LC_MESSAGES/$(PACKAGE).mo; \ + $(INSTALL) -c -m 644 $$l.mo $(INSTALL_LOCALEPATH)/$$l/LC_MESSAGES/$(PACKAGE).mo; \ done %.mo: %.po - msgfmt -o $@ $< + msgfmt -c -o $@ $< update: $(PACKAGE).pot - for n in $(CATALOGS); do \ - l=`basename $$n .mo`; \ + for l in $(LINGUAS); do \ l=$$l".po"; \ mv -f $$l $$l".bac"; \ - msgmerge -o $$l $$l".bac" $(PACKAGE).pot; \ + msgmerge --previous -o $$l $$l".bac" $(PACKAGE).pot; \ done diff --git a/po/messages.po b/po/messages.po deleted file mode 100644 index dfbccfb..0000000 --- a/po/messages.po +++ /dev/null @@ -1,89 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Free Software Foundation, Inc. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-03-16 17:23-0500\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: ENCODING\n" - -#: ../linux_logo.c:38 -msgid "Zero" -msgstr "" - -#: ../linux_logo.c:39 -msgid "One" -msgstr "" - -#: ../linux_logo.c:40 -msgid "Two" -msgstr "" - -#: ../linux_logo.c:41 -msgid "Three" -msgstr "" - -#: ../linux_logo.c:42 -msgid "Four" -msgstr "" - -#: ../linux_logo.c:43 -msgid "Five" -msgstr "" - -#: ../linux_logo.c:44 -msgid "Six" -msgstr "" - -#: ../linux_logo.c:45 -msgid "Seven" -msgstr "" - -#: ../linux_logo.c:46 -msgid "Eight" -msgstr "" - -#: ../linux_logo.c:47 -msgid "Nine" -msgstr "" - -#: ../linux_logo.c:48 -msgid "Many" -msgstr "" - -#. This is the default format of the output file. See the README for more *\ -#. \* information on how to configure this option. -#: ../defaults.h:7 -msgid "" -"#O Version #V, Compiled #C\n" -"#N #M #X #T #P, #R RAM, #B\n" -"#H\n" -msgstr "" - - -#: ../defaults.h:8 -msgid "" -"#O Version #V\n" -"Compiled #C\n" -"#N #M #X #T #P, #R RAM\n" -"#B\n" -"#H\n" -msgstr "" - -#: ../defaults.h:9 -msgid "" -"Processor" -msgstr "" - -#: ../defaults.h:10 -msgid "" -"Processors" -msgstr "" -