Advertisement
Guest User

Symfony2 translations on steroids

a guest
Oct 22nd, 2014
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.42 KB | None | 0 0
  1.  #!/bin/bash
  2.  
  3.  LOCALE="en"
  4.  FORMAT="yml"
  5.  BACKUP="--no-backup "
  6.  
  7.  # Get the options if they were set
  8.  while getopts ":tbl:f:n:" opt; do
  9.      case $opt in
  10.          t)
  11.              if [ -d "src/" ]
  12.                  then
  13.                      echo "Updating twig files to have translations in all variables"
  14.                      `find src/ -type f -name "*.html.twig" | xargs perl -pi -e "s/>([^\s<{>].*?)</>{{ '\1'|trans }}</g"`
  15.              fi
  16.              ;;
  17.          b)
  18.              BACKUP=""
  19.              ;;
  20.          l)
  21.              LOCALE=$OPTARG
  22.              ;;
  23.          f)
  24.              FORMAT=$OPTARG
  25.              ;;
  26.          n)
  27.              if [ -d "src/$OPTARG/Bundle" ]
  28.                  then
  29.                      DIRECTORIES=src/$OPTARG/Bundle/*
  30.                      for d in $DIRECTORIES
  31.                          do
  32.                              module=`basename $d`
  33.                              echo "Processing $OPTARG$module"
  34.  
  35.                              CMD="app/console translation:update --force --output-format=$FORMAT --clean $BACKUP $LOCALE $OPTARG$module"
  36.                              eval $CMD
  37.                      done
  38.              fi
  39.  
  40.              ;;
  41.          \?)
  42.              echo "Invalid option: -$OPTARG" >&2
  43.              exit 1
  44.              ;;
  45.          :)
  46.              echo "Option -$OPTARG requires an argument." >&2
  47.              exit 1
  48.              ;;
  49.      esac
  50.  done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement