copy-to-svn.sh 2.83 KB
Newer Older
bgm's avatar
bgm committed
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#!/bin/sh

# copy-to-svn - copies the compiled .mo files to the SVN l10n repository.
#
# Usage:
#
#  - Change to the root directory of the git repository
#    $ cd l10n/
#
#  - Copy the files
#    $ ./bin/copy-to-svn.sh /path/to/svn/l10n
#
#  - Change to the l10n repository and commit.
#
# For more information:
# http://wiki.civicrm.org/confluence/display/CRMDOC/Localisation+stack

SVNDEST=$1

if [ -z "$SVNDEST" ]; then
  echo "Missing destination directory for the l10n repository."
  echo "usage: ./bin/copy-to-svn.sh /path/to/svn/l10n/"
  exit 1
fi

if [ ! -d "$SVNDEST/fr_FR" ]; then
  echo "$SVNDEST: does not seem to be the l10n directory."
  echo "usage: ./bin/copy-to-svn.sh /path/to/svn/l10n/"
  exit 1
fi

# Start by copying base languages (fr, es, de, ..)
for i in po/??/civicrm.mo; do
  LANG=`echo $i | sed 's|po/\(..\)/civicrm.mo|\1|'`
  REGION=`echo $LANG | tr [:lower:] [:upper:]`

  # Handle a lot of exceptions
  if [ "$LANG" = "he" ]; then
    # Hebrew / Israel
    REGION="IL"
  elif [ "$LANG" = "af" ]; then
    # Afrikaans / South Africa
    REGION="ZA"
  elif [ "$LANG" = "be" ]; then
    # Belarus
    REGION="BY"
  elif [ "$LANG" = "ca" ]; then
    # Catalan / Spain
    REGION="ES"
  elif [ "$LANG" = "cs" ]; then
    # Czech
    REGION="CZ"
  elif [ "$LANG" = "da" ]; then
    # Danish
    REGION="DK"
  elif [ "$LANG" = "ar" ]; then
    # Arabic / Egypt (not sure why.. because of soap operas?)
    REGION="EG"
  elif [ "$LANG" = "ja" ]; then
    # Japanese
    REGION="JP"
  elif [ "$LANG" = "el" ]; then
    # Greek
    REGION="GR"
  elif [ "$LANG" = "et" ]; then
    # Estonian
    REGION="EE"
  elif [ "$LANG" = "hi" ]; then
    # Hindi / India
    REGION="IN"
  elif [ "$LANG" = "sl" ]; then
    # Slovenian
    REGION="SI"
  elif [ "$LANG" = "sq" ]; then
    # Albanian
    REGION="AL"
  elif [ "$LANG" = "sv" ]; then
    # Swedish
    REGION="SE"
  elif [ "$LANG" = "vi" ]; then
    # Vietnam
    REGION="VN"
  fi

  COPYDEST="$SVNDEST/${LANG}_${REGION}/civicrm.mo"

  if [ -f $COPYDEST ]; then
    cp -v $i $COPYDEST
  else
    echo "WARNING: not copying $i, since ${LANG}_${REGION} does not exist in l10n SVN."
    echo "       The directory for new languages must be created manually as a way to"
    echo "       validate the fact that we are adding a new official language to CiviCRM."
  fi
done

# Copy regional languages (fr_CA, es_MX, ..)
for i in po/??_??/civicrm.mo; do
  LANG=`echo $i | sed 's|po/\(.._..\)/civicrm.mo|\1|'`
  REGION=`echo $LANG | tr [:lower:] [:upper:]`

  COPYDEST="$SVNDEST/${LANG}/civicrm.mo"

  if [ -f $COPYDEST ]; then
    cp -v $i $COPYDEST
  else
    echo "WARNING: not copying $i, since ${LANG}_${REGION} does not exist in l10n SVN."
    echo "       The directory for new languages must be created manually as a way to"
    echo "       validate the fact that we are adding a new official language to CiviCRM."
  fi
done