| 1 | #! /bin/bash |
| 2 | |
| 3 | # Copyright (C) 2011, 2012, 2013, 2014 Free Software Foundation, Inc. |
| 4 | |
| 5 | # This file is part of GNUnited Nations. |
| 6 | |
| 7 | # GNUnited Nations is free software: you can redistribute it and/or |
| 8 | # modify it under the terms of the GNU General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | |
| 12 | # GNUnited Nations is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with GNUnited Nations. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | # Wraps around add-fuzzy-diff to provide a command line interface compliant |
| 21 | # with GNU Coding Standards |
| 22 | |
| 23 | function version () { |
| 24 | cat <<EOF |
| 25 | gnun-add-fuzzy-diff (GNUnited Nations) 0.10 |
| 26 | Copyright (C) 2014 Free Software Foundation, Inc. |
| 27 | You may redistribute copies of GNUnited Nations |
| 28 | under the terms of the GNU General Public License. |
| 29 | For more information about these matters, see the file named COPYING. |
| 30 | EOF |
| 31 | } |
| 32 | |
| 33 | function usage () { |
| 34 | cat <<EOF |
| 35 | Usage: gnun-add-fuzzy-diff [OPTION...] [FILE] |
| 36 | Add comments with differences to previous msgids to fuzzy translations |
| 37 | in a PO file. |
| 38 | |
| 39 | Options: |
| 40 | -i[SUFFIX], --in-place[=SUFFIX] |
| 41 | Edit files in place (makes backup if extension supplied) |
| 42 | -v, --version Display version info and exit |
| 43 | -h, --help Display this help and exit |
| 44 | |
| 45 | Report bugs to bug-gnun@gnu.org |
| 46 | GNUnited Nations home page: <https://www.gnu.org/software/gnun/> |
| 47 | General help using GNU software: <http://www.gnu.org/gethelp/> |
| 48 | EOF |
| 49 | } |
| 50 | |
| 51 | function single_file_needed () { |
| 52 | echo 1>&2 "$0:" Single FILE argument is required. |
| 53 | exit 1 |
| 54 | } |
| 55 | |
| 56 | ADD_FUZZY_DIFF=./add-fuzzy-diff |
| 57 | in_place= |
| 58 | file= |
| 59 | |
| 60 | while test $# -ge 1; do |
| 61 | case "$1" in |
| 62 | --help | -h ) |
| 63 | usage |
| 64 | exit 0 |
| 65 | ;; |
| 66 | --version | -v ) |
| 67 | version |
| 68 | exit 0 |
| 69 | ;; |
| 70 | -i* | --in-place=* | --in-place ) |
| 71 | in_place="$1" |
| 72 | ;; |
| 73 | -- ) |
| 74 | shift |
| 75 | break |
| 76 | ;; |
| 77 | -* ) |
| 78 | echo 1>&2 "$0:" Invalid option -- \'$1\'. |
| 79 | exit 1 |
| 80 | ;; |
| 81 | * ) |
| 82 | if test "x$file" = x; then |
| 83 | file="$1" |
| 84 | else |
| 85 | single_file_needed |
| 86 | fi |
| 87 | ;; |
| 88 | esac |
| 89 | shift |
| 90 | done |
| 91 | |
| 92 | if test "x$file" = x; then |
| 93 | if test $# -lt 1; then |
| 94 | single_file_needed |
| 95 | else |
| 96 | file="$1" |
| 97 | shift |
| 98 | fi |
| 99 | fi |
| 100 | if test $# -gt 0; then |
| 101 | single_file_needed |
| 102 | fi |
| 103 | |
| 104 | $ADD_FUZZY_DIFF $in_place "$file" |
| 105 | |
| 106 | exit $? |