As Perch supports multiple languages, apps too have the ability to do so. Language files are created in perch/addons/apps/my_app/lang. During development of your app you should:

As you create your app, text strings from the interface will be added to a new translation file inside the lang folder.

Strings passed through PerchAPI_HTML and PerchAPI_Form are automatically added to the translation. If you write anything to the page directly, you should pass the string through PerchAPI_Lang::get().

$Lang = $API->get('Lang');
echo $Lang->get('Welcome to my app');


The get() method acts a little like sprintf() (and in fact uses sprintf()) to enable string substitutions.

echo $Lang->get('Update the "%s" article', $Article->title());

You should take advantage of this capability when needing to insert dynamic content or markup into translations rather than breaking the string into multiple translations, as it enables the translator to restructure the phrase easily.

Note: it’s important that you don’t write raw strings to the page without pushing them through the translation system, as they won’t be translatable.