diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-12-07 18:42:39 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-12-07 18:43:09 +0100 |
commit | be67eabf88be735a0e50f97efda230cef5a49756 (patch) | |
tree | c341cefded8e287f82796f0ea386c04d4517bb4a | |
parent | inform the user which file cannot be opened on failure (diff) | |
download | scrotty-be67eabf88be735a0e50f97efda230cef5a49756.tar.gz scrotty-be67eabf88be735a0e50f97efda230cef5a49756.tar.bz2 scrotty-be67eabf88be735a0e50f97efda230cef5a49756.tar.xz |
gettext support, does not seem to work...
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | Makefile | 61 | ||||
-rw-r--r-- | po/sv.po | 156 | ||||
-rw-r--r-- | src/scrotty.c | 133 |
3 files changed, 288 insertions, 62 deletions
@@ -4,6 +4,9 @@ # without any warranty. +# The version of the package +VERSION = 1.1 + # The package path prefix, if you want to install to another root, set DESTDIR to that root PREFIX = /usr # The command path excluding prefix @@ -22,6 +25,8 @@ INFODIR = $(DATADIR)/info MANDIR = $(DATADIR)/man # The man page section 1 path including prefix MAN1DIR = $(MANDIR)/man1 +# The locale path including prefix +LOCALEDIR = $(DATADIR)/locale # The license base path including prefix LICENSEDIR = $(DATADIR)/licenses @@ -52,15 +57,22 @@ WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissi # The C standard for C code compilation STD = -std=gnu99 # CPP flags -DEFS = -D'DEVDIR="$(DEVDIR)"' -D'SYSDIR="$(SYSDIR)"' +DEFS = -D'DEVDIR="$(DEVDIR)"' -D'SYSDIR="$(SYSDIR)"' -D'PACKAGE="$(PKGNAME)"' \ + -D'LOCALEDIR="$(LOCALEDIR)"' -D'PROGRAM_VERSION="$(VERSION)"' +ifndef WITHOUT_GETTEXT +DEFS += -D'USE_GETTEXT=1' +endif + +# List of translations. +LOCALES = sv .PHONY: default -default: base info +default: base info locale .PHONY: all -all: base doc +all: base doc locale .PHONY: base base: cmd @@ -107,12 +119,40 @@ bin/%.ps: doc/info/%.texinfo doc/info/fdl.texinfo cd obj/ps && texi2pdf --ps ../../$< < /dev/null mv obj/ps/$*.ps $@ +ifdef WITHOUT_GETTEXT +.PHONY: locale +locale: +else +.PHONY: locale +locale: $(foreach L,$(LOCALES),bin/mo/$(L)/messages.mo) +endif + +bin/mo/%/messages.mo: po/%.po + @mkdir -p bin/mo/$* + cd bin/mo/$* && msgfmt ../../../$< + + +obj/scrotty.pot: src/scrotty.c + @mkdir -p obj + cpp -DUSE_GETTEXT=1 < src/scrotty.c | \ + xgettext -o "$@" -Lc --from-code utf-8 --package-name scrotty \ + --package-version 1.1 --no-wrap --force-po \ + --copyright-holder 'Mattias Andrée (maandree@member.fsf.org)' - + +# Developers: run this to update .po files with new messages. +.PHONY: update-po +update-po: $(foreach L,$(LOCALES),po/$(L).po) + +po/%.po: obj/scrotty.pot + @mkdir -p po + if ! test -e $@; then cp $< $@; else msgmerge -U $@ $<; fi + .PHONY: install -install: install-base install-info install-man +install: install-base install-info install-man install-locale .PHONY: install-all -install-all: install-base install-doc +install-all: install-base install-doc install-locale .PHONY: install-base install-base: install-cmd install-copyright @@ -163,6 +203,16 @@ install-man: doc/man/scrotty.1 install -dm755 -- "$(DESTDIR)$(MAN1DIR)" install -m644 $< -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" +ifdef WITHOUT_GETTEXT +.PHONY: install-locale +install-locale: +else +.PHONY: install-locale +install-locale: + install -dm755 -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES") + $(foreach L,$(LOCALES),install -m644 bin/mo/$(L)/messages.mo -- "$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo" &&) true +endif + .PHONY: uninstall uninstall: @@ -175,6 +225,7 @@ uninstall: -rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).ps" -rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).dvi" -rm -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" + -rm -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo") .PHONY: clean diff --git a/po/sv.po b/po/sv.po new file mode 100644 index 0000000..4fb614d --- /dev/null +++ b/po/sv.po @@ -0,0 +1,156 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Mattias Andrée (maandree@member.fsf.org) +# This file is distributed under the same license as the scrotty package. +# Mattias Andrée <maandree@member.fsf.org>, 2015. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: scrotty 1.1\n" +"POT-Creation-Date: 2015-12-07 18:30+0100\n" +"Last-Translator: Mattias Andrée <maandree@member.fsf.org>\n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: <stdin>:598 +#, fuzzy, c-format +msgid "Saved framebuffer %i to %s,\n" +msgstr "Bildrutebuffert %i sparad till %s.\n" + +#: <stdin>:640 +#, fuzzy, c-format +msgid "" +"SYNOPSIS\n" +"\t%s [options...] [filename-pattern] [-- options-for-convert...]\n" +"\n" +"OPTIONS\n" +"\t--help Print usage information.\n" +"\t--version Print program name and version.\n" +"\t--copyright Print copyright information.\n" +"\t--raw Save in PNM rather than in PNG.\n" +"\t--exec CMD Command to run for each saved image.\n" +"\n" +"SPECIAL STRINGS\n" +"\tBoth the --exec and filename-pattern parameters can take format " +"specifiers\n" +"\tthat are expanded by scrotty when encountered. There are two types of " +"format\n" +"\tspecifier. Characters preceded by a '%%' are interpretted by strftime(3).\n" +"\tSee `man strftime` for examples. These options may be used to refer to " +"the\n" +"\tcurrent date and time. The second kind are internal to scrotty and are " +"prefixed\n" +"\tby '$' or '\\'. The following specifiers are recognised:\n" +"\n" +"\t\n" +"\t$i framebuffer index\n" +"\t$f image filename/pathname (ignored when used in filename-pattern)\n" +"\t$n image filename (ignored when used in filename-pattern)\n" +"\t$p image width multiplied by image height\n" +"\t$w image width\n" +"\t$h image height\n" +"\t$$ expands to a literal '$'\n" +"\t\\n expands to a new line\n" +"\t\\\\ expands to a literal '\\'\n" +"\t\\ expands to a literal ' ' (the string is a backslash followed by a " +"space)\n" +"\n" +"\tA space that is not prefixed by a backslash in --exec is interpreted as " +"an\n" +"\targument delimiter. This is the case even at the beginning and end of the\n" +"\tstring and if a space was the previous character in the string.\n" +"\n" +msgstr "" +"ANVÄNDING\n" +"\t%s [ALTERNATIV...] [FILNAMNSMÖNSTER] [-- ALTERNATIVE_FÖR_CONVERT...]\n" +"\n" +"ALTERNATIV\n" +"\t--help Skriv ut burksanvisningar.\n" +"\t--version Skriv ut programmets namn och version.\n" +"\t--copyright Skriv ut upphovsrätts information.\n" +"\t--raw Spara som PNM-bild snarare än som PNG-bild.\n" +"\t--exec KMD Kommando att köra för varje sparad bild.\n" +"\n" +"SÄRSKILDA STRÄNGS\n" +"\tBåde --exec och filnamnsmönstrets tar formatspecifikationsargument \tsom " +"ersätts av scrotty. Det finns två typer av formatspecifikationsargument." +"\tTecken som direkt följer ett '%%' tolkas av strftime(3). See `man " +"strftime`\n" +"\tför exempel. Dessa alternativ kan användas för att referera till den " +"nuvarande \ttiden and datumet. Den andra typer tolkas av scrotty självt och " +"har ett '$'\teller ett '\\' direkt framför sig. Följande stödjs:\n" +"\n" +"\t\n" +"\t$i Bildrutebuffertens nummer\n" +"\t$f Bildens filename/sökvägsnamn (ignoreras i filnamnsmöstret)\n" +"\t$n Bildens filename (ignoreras i filnamnsmöstret)\n" +"\t$p Bildens brädd multiplicerat med dess höjd\n" +"\t$w Bildens brädd\n" +"\t$h Bildens höjd\n" +"\t$$ Ersätts med en ordagrann '$'\n" +"\t\\n Ersätts med en radbryting\n" +"\t\\\\ Ersätts med en ordagrann '\\'\n" +"\t\\ Ersätts med en ordagrann ' ' (strängen som ersätts slutar med ett " +"mellanrum)\n" +"\n" +"\tMellanrum som inte har ett '\\' direkt framförsig i --exec tolkas som\n" +"\tett argumentskilje. Detta sker även när det förekommer i början och i\n" +"\tslutet av strängen, och om ett sådant även förekom direkt framför.\n" +"\n" + +#: <stdin>:698 +#, fuzzy, c-format +msgid "" +"scrotty -- Screenshot program for Linux's TTY\n" +"Copyright (C) %s\n" +"\n" +"This program is free software: you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation, either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see <http://www.gnu.org/licenses/>.\n" +msgstr "" +"scrotty -- Skärmdumpsprogram för Linux' TTY\n" +"Upphovsrätt (C) %s\n" +"\n" +"Detta program är fri mjukvara: du får vidaredistribuera den och\n" +"modifiera den under villkoren hos GNU General Public License som\n" +"publiseras av Free Software Foundation, antingen version 3 av\n" +"licensen, eller (om du vill) valfri nyare version.\n" +"\n" +"Detta program har distribuerats i hopp om att det kommer att vara\n" +"nyttosamt, men HELT UTAN GARATI; inte ens underförstådd garanti av\n" +"SÄLJBARHET eller LÄMPLIGHET FÖR ETT VISST SYFTE. Läs\n" +"GNU General Public License för mer information.\n" +"\n" +"Du skall ha fått en kopia av GNU General Public License tillsammans\n" +"med det här programmet. Om inte, se <http://www.gnu.org/licenses/>.\n" + +#: <stdin>:763 <stdin>:770 +#, fuzzy, c-format +msgid "%s: %s. Type '%s --help' for help.\n" +msgstr "%s: %s. Kör '%s --help' för hjälp.\n" + +#: <stdin>:763 +#, fuzzy +msgid "Unrecognised option." +msgstr "Val känns inte igen." + +#: <stdin>:770 +#, fuzzy +msgid "--exec has no argument." +msgstr "--exec har inget argument." + +#: <stdin>:807 +#, fuzzy, c-format +msgid "%s: %s: %s\n" +msgstr "%s: %s: %s\n" diff --git a/src/scrotty.c b/src/scrotty.c index 48d9cab..71506c4 100644 --- a/src/scrotty.c +++ b/src/scrotty.c @@ -19,7 +19,7 @@ # define PROGRAM_NAME "scrotty" #endif #ifndef PROGRAM_VERSION -# define PROGRAM_VERSION "1.0" +# define PROGRAM_VERSION "1.1" #endif @@ -36,6 +36,9 @@ #include <stdio.h> #include <alloca.h> #include <time.h> +#ifdef USE_GETTEXT +# include <libintl.h> +#endif #ifndef PATH_MAX @@ -50,6 +53,14 @@ +#ifdef USE_GETTEXT +# define _(STR) gettext (STR) +#else +# define _(STR) STR +#endif + + + /** * Stores a filename to `failure_file` and goes to the label `fail`. * @@ -584,7 +595,7 @@ save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) /* Take a screenshot of the current framebuffer. */ if (save (fbpath, imgpath, width, height) < 0) goto fail; - fprintf (stderr, "Saved framebuffer %i to %s\n", fbno, imgpath); + fprintf (stderr, _("Saved framebuffer %i to %s,\n"), fbno, imgpath); /* Should we run a command over the image? */ if (execpattern == NULL) @@ -626,40 +637,40 @@ save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) static int print_help(void) { - return printf ("SYNOPSIS\n" - "\t%s [options...] [filename-pattern] [-- options-for-convert...]\n" - "\n" - "OPTIONS\n" - "\t--help Print usage information.\n" - "\t--version Print program name and version.\n" - "\t--copyright Print copyright information.\n" - "\t--raw Save in PNM rather than in PNG.\n" - "\t--exec CMD Command to run for each saved image.\n" - "\n" - "SPECIAL STRINGS\n" - "\tBoth the --exec and filename-pattern parameters can take format specifiers\n" - "\tthat are expanded by scrotty when encountered. There are two types of format\n" - "\tspecifier. Characters preceded by a '%%' are interpretted by strftime(3).\n" - "\tSee `man strftime` for examples. These options may be used to refer to the\n" - "\tcurrent date and time. The second kind are internal to scrotty and are prefixed\n" - "\tby '$' or '\\'. The following specifiers are recognised:\n" - "\n" - "\t\n" - "\t$i framebuffer index\n" - "\t$f image filename/pathname (ignored when used in filename-pattern)\n" - "\t$n image filename (ignored when used in filename-pattern)\n" - "\t$p image width multiplied by image height\n" - "\t$w image width\n" - "\t$h image height\n" - "\t$$ expands to a literal '$'\n" - "\t\\n expands to a new line\n" - "\t\\\\ expands to a literal '\\'\n" - "\t\\ expands to a literal ' ' (the string is a backslash followed by a space)\n" - "\n" - "\tA space that is not prefixed by a backslash in --exec is interpreted as an\n" - "\targument delimiter. This is the case even at the beginning and end of the\n" - "\tstring and if a space was the previous character in the string.\n" - "\n", + return printf (_("SYNOPSIS\n" + "\t%s [options...] [filename-pattern] [-- options-for-convert...]\n" + "\n" + "OPTIONS\n" + "\t--help Print usage information.\n" + "\t--version Print program name and version.\n" + "\t--copyright Print copyright information.\n" + "\t--raw Save in PNM rather than in PNG.\n" + "\t--exec CMD Command to run for each saved image.\n" + "\n" + "SPECIAL STRINGS\n" + "\tBoth the --exec and filename-pattern parameters can take format specifiers\n" + "\tthat are expanded by scrotty when encountered. There are two types of format\n" + "\tspecifier. Characters preceded by a '%%' are interpretted by strftime(3).\n" + "\tSee `man strftime` for examples. These options may be used to refer to the\n" + "\tcurrent date and time. The second kind are internal to scrotty and are prefixed\n" + "\tby '$' or '\\'. The following specifiers are recognised:\n" + "\n" + "\t\n" + "\t$i framebuffer index\n" + "\t$f image filename/pathname (ignored when used in filename-pattern)\n" + "\t$n image filename (ignored when used in filename-pattern)\n" + "\t$p image width multiplied by image height\n" + "\t$w image width\n" + "\t$h image height\n" + "\t$$ expands to a literal '$'\n" + "\t\\n expands to a new line\n" + "\t\\\\ expands to a literal '\\'\n" + "\t\\ expands to a literal ' ' (the string is a backslash followed by a space)\n" + "\n" + "\tA space that is not prefixed by a backslash in --exec is interpreted as an\n" + "\targument delimiter. This is the case even at the beginning and end of the\n" + "\tstring and if a space was the previous character in the string.\n" + "\n"), execname) < 0 ? -1 : 0; } @@ -684,21 +695,22 @@ print_version (void) static int print_copyright (void) { - return printf ("scrotty -- Screenshot program for Linux's TTY\n" - "Copyright (C) 2014, 2015 Mattias Andrée (maandree@member.fsf.org)\n" - "\n" - "This program is free software: you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation, either version 3 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with this program. If not, see <http://www.gnu.org/licenses/>.\n" + return printf (_("scrotty -- Screenshot program for Linux's TTY\n" + "Copyright (C) %s\n" + "\n" + "This program is free software: you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation, either version 3 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program. If not, see <http://www.gnu.org/licenses/>.\n"), + "2014, 2015 Mattias Andrée (maandree@member.fsf.org)" ) < 0 ? -1 : 0; } @@ -710,11 +722,11 @@ print_copyright (void) * @param argv Command line arguments * @return Zero on and only on success */ -int main -(int argc, char *argv[]) +int +main (int argc, char *argv[]) { #define EXIT_USAGE(MSG) \ - return fprintf (stderr, "%s: %s. Type `%s --help` for help.\n", execname, MSG, execname), 1 + return fprintf (stderr, _("%s: %s. Type '%s --help' for help.\n"), execname, MSG, execname), 1 int fbno, r, i, dash = argc, exec = -1, help = 0; int raw = 0, version = 0, copyright = 0, filepattern = -1; @@ -724,6 +736,13 @@ int main execname = argc ? *argv : "scrotty"; + /* Set up for internationalisation. */ +#if defined(USE_GETTEXT) && defined(PACKAGE) && defined(LOCALEDIR) + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +#endif + /* Parse command line. */ for (i = 1; i < argc; i++) { @@ -738,14 +757,14 @@ int main break; } else if ((argv[i][0] == '-') || (filepattern != -1)) - EXIT_USAGE ("Unrecognised option."); + EXIT_USAGE (_("Unrecognised option.")); else filepattern = i; } /* Check that --exec is valid. */ if (exec == argc) - EXIT_USAGE ("--exec has no argument."); + EXIT_USAGE (_("--exec has no argument.")); /* Was --help, --version, or --copyright used? */ if (help) return -(print_help ()); @@ -782,7 +801,7 @@ int main if (failure_file == NULL) perror (execname); else - fprintf (stderr, "%s: %s: %s\n", + fprintf (stderr, _("%s: %s: %s\n"), execname, strerror (errno), failure_file); return 1; |