File: copy_po_files_to_lazarus_sources.sh

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (63 lines) | stat: -rwxr-xr-x 1,489 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
#
# Author: Mattias Gaertner
#
# Usage:
#   copy_po_files_to_lazarus_sources.sh LazarusSrcDir file1.po [file2.po] ...
#
# Copies a set of localized .po files to the right location in the lazarus
# source directory.

#set -x
set -e

Usage="$0 LazarusSrcDir file1.po [file2.po] ..."

# get and check lazarus source dir
LazarusSrcDir=$1
if [ ! -d "$LazarusSrcDir" ]; then
  echo $Usage
  exit
fi
echo LazarusSrcDir=$LazarusSrcDir
if [ ! -d "$LazarusSrcDir/lcl/languages" ]; then
  echo Error: $LazarusSrcDir does not look like the Lazarus Source Directory
  exit
fi
shift

# check and copy all .po files to the right directories
POFiles=$@
for POFile in $POFiles; do
  echo $POFile

  # check if .po file exists
  if [ ! -f "$POFile" ]; then
    echo Error: $POFile not found
    exit
  fi

  # check if .po file format file.lang.po
  FileOk=`echo $POFile | sed -e 's/.*\..*\.po$/ok/'`
  if [ "$FileOk" != "ok" ]; then
    echo "Error: $POFile invalid  (expected format: file.lang.po)"
    exit
  fi

  # check if .po file has corresponding base file
  BasePOFile=`echo $POFile | sed -e 's/\(.*\)\..*\(\.po\)$/\1\2/'`
  BasePOFile=`basename $BasePOFile`
  FoundPOFile=`find $LazarusSrcDir -name $BasePOFile`
  if [ ! -f "$FoundPOFile" ]; then
    echo "Error: base .po file not found: $BasePOFile"
    exit
  fi

  # copy the .po file to the same directory as the base .po file
  DestDir=`dirname $FoundPOFile`
  echo "  -> $DestDir/"
  cp $POFile $DestDir/
done

# end.