BUMMZACK

Home

 

SilverStripe Utility: LangBuilder

A script that helps the SilverStripe Module developer to extract all translatable Strings and save them as a file.
This is a command line script that should work on Mac OS X or Linux/Unix with installed PHP. Will be tested soon on Windows. Since the script has to be executable, one must set the according permission bit.

chmod 0755 LangBuilder.php

After that, you can enter the following in your shell:

LangBuilder.php pathto/my/module pathto/output.php

This will search all *.php and *.ss files in the given directory (and its subdirectories) for calls to the translate method (_t). All translatable strings will then be stored in a php file, in above example to: pathto/output.php
Per default, the output directory is: <searchdir>/lang/en_US.php

For a brief help text, just enter:

LangBuilder.php

The extracted Strings can serve as a starting-point for translations.

Please note: This only works for hard-coded string identifiers, not for variables:

// this will work
_t('MyModule.TEST', 'This is a test');

// the following won't work, although it's perfectly valid
$identifier = 'MyModule.TEST';
_t($identifier, 'This is a test');

» Download the LangBuilder Script

Created: 13/04/2009 – Edited: 06/08/2009