Results 1 to 4 of 4

Thread: Recursive msgfmt in src/locale/ subdirs with automatic translation_domain naming

  1. #1
    Join Date
    Dec 2008
    Location
    Kyiv, Ukraine
    Beans
    46

    Exclamation Recursive msgfmt in src/locale/ subdirs with automatic translation_domain naming

    So I'm making test i18n project on pygtk.Builder and was really surprised that process of converting .po files to .mo is completely manual.
    I think msgfmt has to have -r option for recursive and something like --textdomain for automatic .mo renaming.
    Maybe I just can't find the right package or script?
    Are there any instruments for automatic .mo creation? locale/ directory structure is:
    ./uk/LC_MESSAGES/codin.po
    ./C/LC_MESSAGES/codin.pot
    ./ru/LC_MESSAGES/codin.po
    ./en/LC_MESSAGES/codin.po
    Writing a script with find -type f myself...
    Last edited by Interruptor; August 20th, 2010 at 10:50 AM.

  2. #2
    Join Date
    Dec 2008
    Location
    Kyiv, Ukraine
    Beans
    46

    Lightbulb Re: Recursive msgfmt in src/locale/ subdirs with automatic translation_domain naming

    code to run in directory, named as project:
    Attention! See improved version in next reply.
    Code:
    textdomain=`basename "$(pwd)"`
    localedir=`pwd`"/locale/"
    
    for file in `find $localedir -type f -name "*.po"`; do 
    	cd $localedir
    	echo "cd " "$( readlink -f "$( dirname "$file" )" )" && \
    	cd "$( readlink -f "$( dirname "$file" )" )"
    
    	echo "msgfmt -o $textdomain.mo `basename $file`" && \
    	msgfmt -o $textdomain.mo `basename $file`
    	#TODO: for existing .mo - revise only older than .po
    done
    Last edited by Interruptor; August 25th, 2010 at 12:54 PM.

  3. #3
    Join Date
    Dec 2008
    Location
    Kyiv, Ukraine
    Beans
    46

    Lightbulb Re: Recursive msgfmt in src/locale/ subdirs with automatic translation_domain naming

    Improved version for fully-automatic updating:
    Code:
    textdomain=`basename "$(pwd)"`
    localedir=`pwd`"/locale/"
    poeditor="virtaal"
    
    #mv $localedir"C/LC_MESSAGES/"$textdomain".pot $localedir"C/LC_MESSAGES/"$textdomain"`date '+%y%m%d_%H%M'`.pot
    xgettext --sort-output --keyword=translatable -o $localedir"C/LC_MESSAGES/"$textdomain".pot" $textdomain.glade
    
    for file in `find $localedir -type f -name "*.po"`; do 
    	cd $localedir
    	echo "cd " "$( readlink -f "$( dirname "$file" )" )" && \
    	cd "$( readlink -f "$( dirname "$file" )" )"
    	echo "msgmerge -U "$localedir"C/LC_MESSAGES/"$textdomain".pot" && \
    	msgmerge -U $textdomain".po" $localedir"C/LC_MESSAGES/"$textdomain".pot"
    	echo $poeditor $textdomain".po" && \
    	$poeditor $textdomain".po"
    
    	echo "msgfmt -o $textdomain.mo `basename $file`" && \
    	msgfmt -o $textdomain.mo `basename $file`
    	#TODO: for existing .mo - revise only older than .po
    done
    Last edited by Interruptor; August 25th, 2010 at 12:59 PM.

  4. #4
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Recursive msgfmt in src/locale/ subdirs with automatic translation_domain naming

    I think there is a whole system in place using autotools but I haven't progressed into learning that yet.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •