Flourish PHP Unframework

Language system for .po / .mo files

posted by jmtucu 1 year 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!

Reply

@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 1 year ago Reply
In reply to post by mattsah from 1 year ago
In reply to original post by jmtucu