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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #!/bin/bash # # generates gibberish locale for i18n testing # # @author Christopher Han <xiphux@gmail.com> # @copyright Copyright (c) 2012 Christopher Han # @package GitPHP # @subpackage Util # LOCALESRC="locale/gitphp.pot" ZZDIR="locale/zz_Debug" ZZPO="${ZZDIR}/gitphp.po" if [ -e "${ZZPO}" ]; then rm "${ZZPO}" fi mkdir -p "${ZZDIR}" cat "${LOCALESRC}" | \ while read -r LINE; do if [[ $LINE == '# SOME DESCRIPTIVE TITLE'* ]]; then echo "# GitPHP" >> "${ZZPO}" continue fi if [[ $LINE == '# Copyright'* ]]; then echo "# Copyright (C) 2012 Christopher Han" >> "${ZZPO}" continue fi if [[ $LINE == '# This file is distributed'* ]]; then echo "# This file is distributed under the same license as the GitPHP package." >> "${ZZPO}" continue fi if [[ $LINE == '# FIRST AUTHOR'* ]]; then echo "# Christopher Han <xiphux@gmail.com>, 2012." >> "${ZZPO}" continue fi if [[ $LINE == '#, fuzzy'* ]]; then continue fi if [[ $LINE == '"PO-Revision-Date:'* ]]; then echo "\"PO-Revision-Date: `date +\"%Y-%m-%d %H:%M%z\"`\n\"" >> "${ZZPO}" HEADER=1 continue fi if [[ $LINE == '"Last-Translator:'* ]]; then echo "\"Last-Translator: Christopher Han <xiphux@gmail.com>\n\"" >> "${ZZPO}" HEADER=1 continue fi if [[ $LINE == '"Language-Team:'* ]]; then echo "\"Language-Team: Christopher Han <xiphux@gmail.com>\n\"" >> "${ZZPO}" HEADER=1 continue fi if [[ $LINE == '"Language:'* ]]; then echo "\"Language: Gibberish\n\"" >> "${ZZPO}" HEADER=1 continue fi if [[ $LINE == '"Plural-Forms:'* ]]; then echo "\"Plural-Forms: nplurals=2; plural=n != 1;\n\"" >> "${ZZPO}" HEADER=1 continue fi if [[ $LINE == 'msgid '* ]]; then if [[ $HEADER != 1 ]]; then echo "${LINE}" >> "${ZZPO}" continue fi MSG="${LINE}" while read -r LINE; do if [[ "$LINE" == "" ]] || [[ "$LINE" == '#'* ]]; then break fi if [[ ! "$LINE" == 'msgstr'* ]]; then MSG="${MSG}\n${LINE}" fi done echo -e "${MSG}" >> "${ZZPO}" MSGSTR="$MSG" if [[ "${MSG}" == *'msgid_plural'* ]]; then MSGSTR="${MSGSTR/msgid_plural/msgstr[1]}" MSGSTR="${MSGSTR/msgid/msgstr[0]}" else MSGSTR="${MSGSTR/msgid/msgstr}" fi echo -e "${MSGSTR}" | \ while read -r LINE2; do PREFIX="`echo "${LINE2}" | sed -e 's/".*//'`" STRING="`echo "${LINE2}" | sed -e 's/^[^"]*"//' | sed -e 's/"$//'`" if [[ "${STRING}" == "English" ]]; then # special locale name token STRING="Gibberish" elif [[ ! "${STRING}" == "" ]]; then # pad string 30% to account for longer languages STRPADDING=$((${#STRING}*30/100)) STRPADDING=$((${STRPADDING}+1)) # because of integer truncation for ((i=1; i <= STRPADDING; i++)); do STRING="${STRING}•" done # add non-english characters STRING="${STRING//a/â}" STRING="${STRING//e/ȩ}" STRING="${STRING//i/ȉ}" STRING="${STRING//o/ø}" STRING="${STRING//u/ü}" STRING="${STRING//A/Å}" STRING="${STRING//E/Ȅ}" STRING="${STRING//I/Ĭ}" STRING="${STRING//O/Ɵ}" STRING="${STRING//U/Ṳ}" # flag inserted tokens with asterisks STRING="`echo "${STRING/\$/\\\$}" | sed -e 's/\(%[1-9]\(\$[a-z]\)\?\)/\*\1\*/g'`" # add boundary markers STRING="{${STRING}}" fi echo "${PREFIX}\"${STRING}\"" >> "${ZZPO}" done fi echo "${LINE}" >> "${ZZPO}" done |