24 lines
15 KiB
Text
24 lines
15 KiB
Text
version=pmwiki-1.0.5
|
|
newline=²
|
|
text=Here's a proposal for using the GNU gettext tools to do the coding / translation / compiling cycle on translated applications.²²The sample bash scripts used here follow below. The scripts are originally from the SuirrelMail web application.²²'''Note:'''²* I have tested these scripts on Windows, using a Cygwin environment.²* This works on the sample application mentioned in the Gettext tutorial (http://gtk.php.net/manual/en/tutorials.translation.php).²²! Install the scripts²²* In the main application's directory, create a directory '''po'''.²* Copy the scripts '''gettext.conf''', '''xgetpo''', '''mergepo''', '''createpo''' and '''compilepo''' to the '''po''' sub-directory.²* Enter the application's directory name in the file '''gettext.conf''':²²APP_NAME=ex_gettext²²! Create a '''.pot'''-file²* Change to the applications's '''po''' subdir.²* Run '''xgetpo'''. The script parses all php files and dumps the strings to translate (e.g. _"This is a phrase") into a file named '''APP_NAME.pot'''. APP_NAME is as entered in the '''gettext.conf''' file (s.a.).²²! Creating translation files for other languages²* Change to the applications's '''po''' subdir.²* Run e.g. '''createpo de_DE'''. You will be asked to enter the translator's email address. Then, a directory structure '''locale/de_DE/LC_MESSAGES''' will be created below the APP_NAME directory.²* Go into locale/de_DE/LC_MESSAGES and translate the '''APP_NAME.po''' file.²* '''Note:''' In the '''.po''' file, there is a line '''Content-Type: text/plain; charset=ASCII'''. E.g. for german letters, change ASCII to '''ISO-8859-15''' or anything appropriate.²* For every '''msgid''' line, enter the translation in the following '''msgstr''', between the double quotes.²²! Compile the PO Files²* Change to the application's '''po''' subdir.²* Run '''compilepo de_DE'''. This compiles the de_DE/.../APP_NAME.po file to a binary '''.mo''' file.²²! Continuing the Cycle²* When you have added some phrases to the source code, do:²** cd po²** xgetpo²** mergepo de_DE²** translate the new phrases in locale/de_DE/LC_MESSAGES/APP_NAME.po²** compilepo de_DE²** Test you application :-)²²Hope this is usefull.²²Have fun!²²Joachim Werner <joachim.werner@diggin-data.de>²²!! gettext.conf²[[include:Main/CodeTable]]²#!/bin/bash²APP_NAME=ex_gettext²[[include:Main/CodeTableEnd]]²²!! xgetpo²[[include:Main/CodeTable]]²#!/bin/sh²²# ** --- xgetpo ---²# **²# ** This script regenerates main POT file²# ** ²# ** taken from www.squirrelmail.org²# ** Original Author: Philipe Mingo <mingo@rotedic.com>²². ./gettext.conf²²XGETTEXT_OPTIONS="--keyword=_ -keyword=N_ --language=PHP --default-domain=$APP_NAME --no-location"²echo "XGETTEXT_OPTIONS: $XGETTEXT_OPTIONS"²²cd ../..²²xgettext ${XGETTEXT_OPTIONS} \²$APP_NAME/*.php --output=$APP_NAME/po/$APP_NAME.pot² ²# additional directories²# xgettext ${XGETTEXT_OPTIONS} \²-j $APP_NAME/config/*.php --output=$APP_NAME/po/$APP_NAME.pot²²cd $APP_NAME/po²²[[include:Main/CodeTableEnd]]²²!! createpo²[[include:Main/CodeTable]]²#!/bin/sh²²# ** -- createpo ---²# ** ²# ** This script creates a locale PO file.²# **²# ** Usage: createpo <locale id>²# ** Example: createpo de_DE²# **²# ** Joachim Werner <info@diggin-data.de>²# **²². ./gettext.conf²²if [ -z "$1" ]; then² echo "USAGE: createpo [localename]"² exit 1²fi²²²WORKDIR=../locale²LOCALEDIR=$WORKDIR/$1/LC_MESSAGES²²mkdir -p $LOCALEDIR²²if [ ! -d $LOCALEDIR ]; then² echo "Couldn't create $LOCALEDIR."² exit 1²fi²²msginit -l $1 -i $APP_NAME.pot -o $LOCALEDIR/$APP_NAME.po²²DCOUNT=`find -name $LOCALEDIR/$APP_NAME.po | wc -l` ²if [ $DCOUNT -eq 1 ]; then ²fi²[[include:Main/CodeTableEnd]]²²!! mergepo²[[include:Main/CodeTable]]²#!/bin/sh²²# ** --- mergepo ---²# **²# ** This script merges global POT to locale PO files.²# ** It creates a backup of the old PO file as vexim_jw.po.bak²# ** and puts the merged version in vexim_jw.po²# **²# ** Usage: mergepo <locale id>²# ** Example: mergepo es_ES²# **²# ** Philipe Mingo <mingo@rotedic.com>²# ** Konstantin Riabitsev <icon@duke.edu>²# **²². gettext.conf²²if [ -z "$1" ]; then² echo "USAGE: mergepo [localename]"² exit 1²fi²²WORKDIR=../locale²LOCALEDIR=$WORKDIR/$1²²if [ ! -d $LOCALEDIR ]; then² # lessee if it's been renamed.² DCOUNT=`find $WORKDIR/ -name $1* | wc -l` ² if [ $DCOUNT -eq 1 ]; then ² # aha² LOCALEDIR=`find $WORKDIR/ -name $1*`² elif [ $DCOUNT -gt 1 ]; then² # err out² echo "More than one locale matching this name found:"² find $WORKDIR/ -name $1*² echo "You have to be more specific."² exit 1² fi²fi²²echo "Merging $LOCALEDIR/LC_MESSAGES/$APP_NAME.po"²mv $LOCALEDIR/LC_MESSAGES/$APP_NAME.po \² $LOCALEDIR/LC_MESSAGES/$APP_NAME.po.bak ²msgmerge $LOCALEDIR/LC_MESSAGES/$APP_NAME.po.bak ../po/$APP_NAME.pot > \² $LOCALEDIR/LC_MESSAGES/$APP_NAME.po²²# msgmerge will split long lines, such as the RCS Id line. If it did split²# it, join the pieces back together.²ed -s $LOCALEDIR/LC_MESSAGES/$APP_NAME.po << END²/^"Project-Id-Version:/v/\\n"$/j\\²s/""//²wq²END²²echo "Old po file renamed to $APP_NAME.po.bak"²²[[include:Main/CodeTableEnd]]²²!! compilepo²[[include:Main/CodeTable]]²#!/bin/sh²²# ** --- compilepo ---²# ** This script compiles locale PO files²# **²# ** Usage: compilepo <locale id>²# ** Example: compilepo es²# **²# ** Philipe Mingo <mingo@rotedic.com>²# ** Konstantin Riabitsev <icon@duke.edu>²². gettext.conf²²if [ -z "$1" ]; then² echo "USAGE: compilepo [localename]"² exit 1²fi²²WORKDIR=../locale²LOCALEDIR=$WORKDIR/$1²²if [ ! -d $LOCALEDIR ]; then² # lessee if it's been renamed.² DCOUNT=`find $WORKDIR/ -name $1* | wc -l` ² if [ $DCOUNT -eq 1 ]; then ² # aha² LOCALEDIR=`find $WORKDIR/ -name $1*`² elif [ $DCOUNT -gt 1 ]; then² # err out² echo "More than one locale matching this name found:"² find $WORKDIR/ -name $1*² echo "You have to be more specific."² exit 1² fi²fi²²echo "Compiling $LOCALEDIR/LC_MESSAGES/$APP_NAME.po"²msgfmt -o $LOCALEDIR/LC_MESSAGES/$APP_NAME.mo \² $LOCALEDIR/LC_MESSAGES/$APP_NAME.po²²[[include:Main/CodeTableEnd]]²²
|
|
time=1117269952
|
|
diff:1108389885:1108389885:=1,221c1²< Here's a proposal for using the GNU gettext tools to do the coding / translation / compiling cycle on translated applications.²< ²< The sample bash scripts used here follow below. The scripts are originally from the SuirrelMail web application.²< ²< * '''Note:''' I have tested these scripts on Windows, using a Cygwin environment.²< ²< ! Install the scripts²< ²< * In the main application's directory, create a directory '''po'''.²< * Copy the scripts '''gettext.conf''', '''xgetpo''', '''mergepo''', '''createpo''' and '''compilepo''' to the '''po''' sub-directory.²< * Enter the application's directory name in the file '''gettext.conf''':²< ²< APP_NAME=ex_gettext²< ²< ! Create a '''.pot'''-file²< * Change to the applications's '''po''' subdir.²< * Run '''xgetpo'''. The script parses all php files and dumps the strings to translate (e.g. _"This is a phrase") into a file named '''APP_NAME.pot'''. APP_NAME is as entered in the '''gettext.conf''' file (s.a.).²< ²< ! Creating translation files for other languages²< * Change to the applications's '''po''' subdir.²< * Run e.g. '''createpo de_DE'''. You will be asked to enter the translator's email address. Then, a directory structure '''locale/de_DE/LC_MESSAGES''' will be created below the APP_NAME directory.²< * Go into locale/de_DE/LC_MESSAGES and translate the '''APP_NAME.po''' file.²< * '''Note:''' In the '''.po''' file, there is a line '''Content-Type: text/plain; charset=ASCII'''. E.g. for german letters, change ASCII to '''ISO-8859-15''' or anything appropriate.²< * For every '''msgid''' line, enter the translation in the following '''msgstr''', between the double quotes.²< ²< ! Compile the PO Files²< * Change to the applications's '''po''' subdir.²< * Run '''compilepo de_DE'''. This compiles the de_DE/.../APP_NAME.po file to a binary '''.mo''' file.²< ²< ! Continuing the Cycle²< * When you have added some phrases to the source code, do:²< ** cd po²< ** xgetpo²< ** mergepo de_DE²< ** translate the new phrases in locale/de_DE/LC_MESSAGES/APP_NAME.po²< ** compilepo de_DE²< ** Test you application :-)²< ²< Hope this is usefull.²< ²< Have fun!²< ²< Joachim Werner <joachim.werner@diggin-data.de>²< ²< !! gettext.conf²< [[include:Main/CodeTable]]²< #!/bin/bash²< APP_NAME=ex_gettext²< [[include:Main/CodeTableEnd]]²< ²< !! xgetpo²< [[include:Main/CodeTable]]²< #!/bin/sh²< ²< # ** --- xgetpo ---²< # **²< # ** This script regenerates main POT file²< # ** ²< # ** taken from www.squirrelmail.org²< # ** Original Author: Philipe Mingo <mingo@rotedic.com>²< ²< . ./gettext.conf²< ²< XGETTEXT_OPTIONS="--keyword=_ -keyword=N_ --language=PHP --default-domain=$APP_NAME --no-location"²< echo "XGETTEXT_OPTIONS: $XGETTEXT_OPTIONS"²< ²< cd ../..²< ²< xgettext ${XGETTEXT_OPTIONS} \²< $APP_NAME/*.php --output=$APP_NAME/po/$APP_NAME.pot²< ²< # additional directories²< # xgettext ${XGETTEXT_OPTIONS} \²< -j $APP_NAME/config/*.php --output=$APP_NAME/po/$APP_NAME.pot²< ²< cd $APP_NAME/po²< ²< [[include:Main/CodeTableEnd]]²< ²< !! createpo²< [[include:Main/CodeTable]]²< #!/bin/sh²< ²< # ** -- createpo ---²< # ** ²< # ** This script creates a locale PO file.²< # **²< # ** Usage: createpo <locale id>²< # ** Example: createpo de_DE²< # **²< # ** Joachim Werner <info@diggin-data.de>²< # **²< ²< . ./gettext.conf²< ²< if [ -z "$1" ]; then²< echo "USAGE: createpo [localename]"²< exit 1²< fi²< ²< ²< WORKDIR=../locale²< LOCALEDIR=$WORKDIR/$1/LC_MESSAGES²< ²< mkdir -p $LOCALEDIR²< ²< if [ ! -d $LOCALEDIR ]; then²< echo "Couldn't create $LOCALEDIR."²< exit 1²< fi²< ²< msginit -l $1 -i $APP_NAME.pot -o $LOCALEDIR/$APP_NAME.po²< ²< DCOUNT=`find -name $LOCALEDIR/$APP_NAME.po | wc -l` ²< if [ $DCOUNT -eq 1 ]; then ²< fi²< [[include:Main/CodeTableEnd]]²< ²< !! mergepo²< [[include:Main/CodeTable]]²< #!/bin/sh²< ²< # ** --- mergepo ---²< # **²< # ** This script merges global POT to locale PO files.²< # ** It creates a backup of the old PO file as vexim_jw.po.bak²< # ** and puts the merged version in vexim_jw.po²< # **²< # ** Usage: mergepo <locale id>²< # ** Example: mergepo es_ES²< # **²< # ** Philipe Mingo <mingo@rotedic.com>²< # ** Konstantin Riabitsev <icon@duke.edu>²< # **²< ²< . gettext.conf²< ²< if [ -z "$1" ]; then²< echo "USAGE: mergepo [localename]"²< exit 1²< fi²< ²< WORKDIR=../locale²< LOCALEDIR=$WORKDIR/$1²< ²< if [ ! -d $LOCALEDIR ]; then²< # lessee if it's been renamed.²< DCOUNT=`find $WORKDIR/ -name $1* | wc -l` ²< if [ $DCOUNT -eq 1 ]; then ²< # aha²< LOCALEDIR=`find $WORKDIR/ -name $1*`²< elif [ $DCOUNT -gt 1 ]; then²< # err out²< echo "More than one locale matching this name found:"²< find $WORKDIR/ -name $1*²< echo "You have to be more specific."²< exit 1²< fi²< fi²< ²< echo "Merging $LOCALEDIR/LC_MESSAGES/$APP_NAME.po"²< mv $LOCALEDIR/LC_MESSAGES/$APP_NAME.po \²< $LOCALEDIR/LC_MESSAGES/$APP_NAME.po.bak ²< msgmerge $LOCALEDIR/LC_MESSAGES/$APP_NAME.po.bak ../po/$APP_NAME.pot > \²< $LOCALEDIR/LC_MESSAGES/$APP_NAME.po²< ²< # msgmerge will split long lines, such as the RCS Id line. If it did split²< # it, join the pieces back together.²< ed -s $LOCALEDIR/LC_MESSAGES/$APP_NAME.po << END²< /^"Project-Id-Version:/v/\\n"$/j\\²< s/""//²< wq²< END²< ²< echo "Old po file renamed to $APP_NAME.po.bak"²< ²< [[include:Main/CodeTableEnd]]²< ²< !! compilepo²< [[include:Main/CodeTable]]²< #!/bin/sh²< ²< # ** --- compilepo ---²< # ** This script compiles locale PO files²< # **²< # ** Usage: compilepo <locale id>²< # ** Example: compilepo es²< # **²< # ** Philipe Mingo <mingo@rotedic.com>²< # ** Konstantin Riabitsev <icon@duke.edu>²< ²< . gettext.conf²< ²< if [ -z "$1" ]; then²< echo "USAGE: compilepo [localename]"²< exit 1²< fi²< ²< WORKDIR=../locale²< LOCALEDIR=$WORKDIR/$1²< ²< if [ ! -d $LOCALEDIR ]; then²< # lessee if it's been renamed.²< DCOUNT=`find $WORKDIR/ -name $1* | wc -l` ²< if [ $DCOUNT -eq 1 ]; then ²< # aha²< LOCALEDIR=`find $WORKDIR/ -name $1*`²< elif [ $DCOUNT -gt 1 ]; then²< # err out²< echo "More than one locale matching this name found:"²< find $WORKDIR/ -name $1*²< echo "You have to be more specific."²< exit 1²< fi²< fi²< ²< echo "Compiling $LOCALEDIR/LC_MESSAGES/$APP_NAME.po"²< msgfmt -o $LOCALEDIR/LC_MESSAGES/$APP_NAME.mo \²< $LOCALEDIR/LC_MESSAGES/$APP_NAME.po²< ²< [[include:Main/CodeTableEnd]]²\ No newline at end of file²---²> Describe UsingGettextTools here.²\ No newline at end of file²
|
|
author=Mike
|
|
author:1108389885=joachim_werner
|
|
host:1108389885=192.85.16.3
|
|
name=CodeSnippets.UsingGettextTools
|
|
host=84.146.159.150
|
|
agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1
|
|
rev=5
|
|
diff:1108390014:1108389885:=5,7c5²< '''Note:'''²< * I have tested these scripts on Windows, using a Cygwin environment.²< * This works on the sample application mentioned in the Gettext tutorial (http://gtk.php.net/manual/en/tutorials.translation.php).²---²> * '''Note:''' I have tested these scripts on Windows, using a Cygwin environment.²
|
|
author:1108390014=joachim_werner
|
|
host:1108390014=192.85.16.3
|
|
diff:1108390285:1108390014:=29c29²< * Change to the application's '''po''' subdir.²---²> * Change to the applications's '''po''' subdir.²
|
|
author:1108390285=joachim_werner
|
|
host:1108390285=192.85.16.3
|
|
diff:1117219112:1108390285:=223,237c223²< [[include:Main/CodeTableEnd]]²< ²< ==Links==²< ²< [[http://valium1.dezigner.ru/ valium]]²< [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²< [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²< [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²< [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²< [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²< [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²< [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²< [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²< [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²< [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²---²> [[include:Main/CodeTableEnd]]²\ No newline at end of file²
|
|
author:1117219112=a
|
|
host:1117219112=62.33.112.3
|
|
diff:1117269952:1117219112:=224a225,237²> ==Links==²> ²> [[http://valium1.dezigner.ru/ valium]]²> [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²> [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²> [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²> [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²> [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²> [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²> [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²> [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²> [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²> [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²
|
|
author:1117269952=Mike
|
|
host:1117269952=84.146.159.150
|