Dotclear


Ignore:
Timestamp:
07/26/18 16:19:33 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Update locales

File:
1 edited

Legend:

Unmodified
Added
Removed
  • build-tools/po_update.sh

    r3731 r3784  
    4141 
    4242if [ ! -d ./inc/core ]; then 
    43      echo "You are not on Dotclear root directory" 
    44      exit 1 
     43  echo "You are not on Dotclear root directory" 
     44  exit 1 
    4545fi 
    4646 
    4747if [ ! -d locales/_pot ]; then 
    48      echo "Template not found." 
    49      exit 1 
     48  echo "Template not found." 
     49  exit 1 
    5050fi 
    5151 
    5252extract_strings() 
    5353{ 
    54      $XGETTEXT \ 
    55      -f- \ 
    56      --sort-by-file \ 
    57      -L PHP -k"__:1,2" -k"__:1" \ 
    58      --no-wrap \ 
    59      --foreign-user \ 
    60      --from-code=UTF-8 \ 
    61      "$@" 
     54  $XGETTEXT \ 
     55  -f- \ 
     56  --sort-by-file \ 
     57  -L PHP -k"__:1,2" -k"__:1" \ 
     58  --no-wrap \ 
     59  --foreign-user \ 
     60  --from-code=UTF-8 \ 
     61  "$@" 
    6262} 
    6363 
    6464extract_html_strings() 
    6565{ 
    66      tee - 
     66  tee - 
    6767 
    68      $XGETTEXT \ 
    69      - \ 
    70      --sort-by-file \ 
    71      -L PHP -k__ \ 
    72      --no-wrap \ 
    73      --foreign-user \ 
    74      --from-code=UTF-8 \ 
    75      "$@" 
     68  $XGETTEXT \ 
     69  - \ 
     70  --sort-by-file \ 
     71  -L PHP -k__ \ 
     72  --no-wrap \ 
     73  --foreign-user \ 
     74  --from-code=UTF-8 \ 
     75  "$@" 
    7676} 
    7777update_po() 
    7878{ 
    79      po_file=$1 
    80      pot_file=$2 
    81      po_dir=`dirname $1` 
    82      po_tmp=$po_dir/tmp.po~ 
     79  po_file=$1 
     80  pot_file=$2 
     81  po_dir=`dirname $1` 
     82  po_tmp=$po_dir/tmp.po~ 
    8383 
    84      if [ ! -d $po_dir ]; then 
    85           mkdir $po_dir 
    86      fi 
     84  if [ ! -d $po_dir ]; then 
     85    mkdir $po_dir 
     86  fi 
    8787 
    88      if [ ! -f $po_file ]; then 
    89           cp $pot_file $po_file 
    90           perl -pi -e "s|; charset=CHARSET|; charset=UTF-8|sgi;" $po_file $po_file 
    91      fi 
     88  if [ ! -f $po_file ]; then 
     89    cp $pot_file $po_file 
     90    perl -pi -e "s|; charset=CHARSET|; charset=UTF-8|sgi;" $po_file $po_file 
     91  fi 
    9292 
    93      $MSGMERGE --no-location --no-wrap -o $po_tmp $po_file $pot_file 
    94      mv $po_tmp $po_file 
     93  $MSGMERGE --no-location --no-wrap -o $po_tmp $po_file $pot_file 
     94  mv $po_tmp $po_file 
    9595} 
    9696 
    9797if [ -z "$PO_MODULE" ]; then 
    98      # 
    99      # Create po template files 
    100      # 
    101      echo "Building main PO template..." 
    102      find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -print | \ 
    103           extract_strings \ 
    104           --package-name="Dotclear 2" \ 
    105           -o locales/_pot/main.pot \ 
    106           -x locales/_pot/date.pot 
     98  # 
     99  # Create po template files 
     100  # 
     101  echo "Building main PO template..." 
     102  find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -not -regex '.*/inc/libs/.*' -print | \ 
     103    extract_strings \ 
     104    --package-name="Dotclear 2" \ 
     105    -o locales/_pot/main.pot \ 
     106    -x locales/_pot/date.pot 
    107107 
    108      echo "DONE" 
     108  echo "DONE" 
    109109 
    110      # plugins.pot 
    111      echo "Building plugins PO template..." 
    112      for p in $PLUGINS; do 
    113           if [ -d plugins/$p ]; then 
    114                find ./plugins/$p -name '*.php' -print 
    115           fi 
    116      done | \ 
    117           extract_strings \ 
    118           --package-name="Dotclear 2" \ 
    119           -o locales/_pot/plugins.pot \ 
    120           -x locales/_pot/date.pot \ 
    121           -x locales/_pot/main.pot 
     110  # plugins.pot 
     111  echo "Building plugins PO template..." 
     112  for p in $PLUGINS; do 
     113    if [ -d plugins/$p ]; then 
     114      find ./plugins/$p -name '*.php' -print 
     115    fi 
     116  done | \ 
     117    extract_strings \ 
     118    --package-name="Dotclear 2" \ 
     119    -o locales/_pot/plugins.pot \ 
     120    -x locales/_pot/date.pot \ 
     121    -x locales/_pot/main.pot 
    122122 
    123      echo "DONE" 
     123  echo "DONE" 
    124124 
    125      # 
    126      # Update locales/<lang> if needed 
    127      # 
    128      if [ -z "$PO_LANG" ]; then 
    129           exit 0; 
    130      fi 
     125  # 
     126  # Update locales/<lang> if needed 
     127  # 
     128  if [ -z "$PO_LANG" ]; then 
     129    exit 0; 
     130  fi 
    131131 
    132      # Init locale if not present 
    133      if [ ! -d locales/$PO_LANG ]; then 
    134           mkdir -p locales/$PO_LANG/help 
     132  # Init locale if not present 
     133  if [ ! -d locales/$PO_LANG ]; then 
     134    mkdir -p locales/$PO_LANG/help 
    135135 
    136           # Base help files 
    137           for i in locales/en/help/*.html; do 
    138                cp $i locales/$PO_LANG/help/core_`basename $i` 
    139           done 
    140           for i in $PLUGINS; do 
    141                if [ -f plugins/$i/help.html ]; then 
    142                     cp plugins/$i/help.html locales/$PO_LANG/help/$i.html 
    143                fi 
    144           done 
    145      fi 
     136    # Base help files 
     137    for i in locales/en/help/*.html; do 
     138      cp $i locales/$PO_LANG/help/core_`basename $i` 
     139    done 
     140    for i in $PLUGINS; do 
     141      if [ -f plugins/$i/help.html ]; then 
     142        cp plugins/$i/help.html locales/$PO_LANG/help/$i.html 
     143      fi 
     144    done 
     145  fi 
    146146 
    147      # update main.po 
    148      echo "Updating <$PO_LANG> po files..." 
    149      update_po ./locales/$PO_LANG/main.po ./locales/_pot/main.pot 
    150      update_po ./locales/$PO_LANG/plugins.po ./locales/_pot/plugins.pot 
    151      update_po ./locales/$PO_LANG/public.po ./locales/_pot/public.pot 
    152      update_po ./locales/$PO_LANG/date.po ./locales/_pot/date.pot 
     147  # update main.po 
     148  echo "Updating <$PO_LANG> po files..." 
     149  update_po ./locales/$PO_LANG/main.po ./locales/_pot/main.pot 
     150  update_po ./locales/$PO_LANG/plugins.po ./locales/_pot/plugins.pot 
     151  update_po ./locales/$PO_LANG/public.po ./locales/_pot/public.pot 
     152  update_po ./locales/$PO_LANG/date.po ./locales/_pot/date.pot 
    153153else 
    154      # 
    155      # Plugin language update 
    156      # 
     154  # 
     155  # Plugin language update 
     156  # 
    157157 
    158      if [ ! -d $PO_MODULE ]; then 
    159           echo "Module $PO_MODULE does not exist" 
    160           exit 1 
    161      fi 
    162      echo "Module $PO_MODULE language update" 
     158  if [ ! -d $PO_MODULE ]; then 
     159    echo "Module $PO_MODULE does not exist" 
     160    exit 1 
     161  fi 
     162  echo "Module $PO_MODULE language update" 
    163163 
    164164 
    165      # 
    166      # Building po template file 
    167      # 
    168      if [ ! -d $PO_MODULE/locales/_pot ]; then 
    169           mkdir -p $PO_MODULE/locales/_pot 
    170      fi 
    171      echo "Building main PO template..." 
    172      echo '<?php' >$PO_MODULE/__html_tpl_dummy.php 
    173      find $PO_MODULE -name '*.html' -exec grep -o '{{tpl:lang [^}]*}}' {} \; | sed 's/{{tpl:lang \(.*\)}}$/__\("\1")/' | sort -u \ 
    174           >> $PO_MODULE/__html_tpl_dummy.php 
    175      sed -i "" 's/\$/\\\$/g' $PO_MODULE/__html_tpl_dummy.php 
     165  # 
     166  # Building po template file 
     167  # 
     168  if [ ! -d $PO_MODULE/locales/_pot ]; then 
     169    mkdir -p $PO_MODULE/locales/_pot 
     170  fi 
     171  echo "Building main PO template..." 
     172  echo '<?php' >$PO_MODULE/__html_tpl_dummy.php 
     173  find $PO_MODULE -name '*.html' -exec grep -o '{{tpl:lang [^}]*}}' {} \; | sed 's/{{tpl:lang \(.*\)}}$/__\("\1")/' | sort -u \ 
     174    >> $PO_MODULE/__html_tpl_dummy.php 
     175  sed -i "" 's/\$/\\\$/g' $PO_MODULE/__html_tpl_dummy.php 
    176176 
    177      find $PO_MODULE -name '*.php' -print | \ 
    178           extract_strings \ 
    179           --package-name="Dotclear 2 `basename $PO_MODULE` module" \ 
    180           -o $PO_MODULE/locales/_pot/main.pot \ 
    181           -x locales/_pot/date.pot -x locales/_pot/main.pot -x locales/_pot/public.pot -x locales/_pot/plugins.pot 
     177  find $PO_MODULE -name '*.php' -print | \ 
     178    extract_strings \ 
     179    --package-name="Dotclear 2 `basename $PO_MODULE` module" \ 
     180    -o $PO_MODULE/locales/_pot/main.pot \ 
     181    -x locales/_pot/date.pot -x locales/_pot/main.pot -x locales/_pot/public.pot -x locales/_pot/plugins.pot 
    182182 
    183      rm -f $PO_MODULE/__html_tpl_dummy.php 
     183  rm -f $PO_MODULE/__html_tpl_dummy.php 
    184184 
    185      echo "DONE" 
     185  echo "DONE" 
    186186 
    187      # 
    188      # Update locale/<lang> 
    189      # 
    190      if [ ! -d $PO_MODULE/locales/$PO_LANG ]; then 
    191           mkdir -p $PO_MODULE/locales/$PO_LANG 
    192      fi 
    193      echo "Updating module <$PO_MODULE> main <$PO_LANG> po file... " 
    194      update_po $PO_MODULE/locales/$PO_LANG/main.po $PO_MODULE/locales/_pot/main.pot 
     187  # 
     188  # Update locale/<lang> 
     189  # 
     190  if [ ! -d $PO_MODULE/locales/$PO_LANG ]; then 
     191    mkdir -p $PO_MODULE/locales/$PO_LANG 
     192  fi 
     193  echo "Updating module <$PO_MODULE> main <$PO_LANG> po file... " 
     194  update_po $PO_MODULE/locales/$PO_LANG/main.po $PO_MODULE/locales/_pot/main.pot 
    195195fi 
Note: See TracChangeset for help on using the changeset viewer.

Sites map