Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Language system for .po / .mo files

posted by jmtucu 7 years ago

Hi! Can I use a .mo file to translate an application? I don't know how to use it, actually I'm using an array() to store all the translations but I want to use a .mo file because it's more easy to translate.

fText::compose() use gettext?

Thanks in advanced!

@jmtucu

fText::compose() pretty much takes your string and passes it through the registered compose callback, and returns the value that the callback returns. So hypothetically, you can do anything that PHP can do inside that callback.

For example, you could return the string value modified by str_rot13 and ROT13 "encode" all your strings.

So really, assuming you do all the necessary configuration for getText you can simply register a callback that returns gettext($string).

fText::registerComposeCallback('pre', function($untranslated_string){
    return gettext($untranslated_string);
});
posted by mattsah 7 years ago