bernhard Posted February 22, 2023 Share Posted February 22, 2023 NOTE (2024-10-11): No special syntax needed any more! I'm so happy about that feature that I think it's worth having a new thread for it! ? You can now use regular PW translation features directly from within your LATTE files!! All you need to do is this: make sure you have PW >= 3.0.212 add the "latte" extension to ProcessLanguageTranslator's module config (or use the checkbox in RockFrontend's module config if you are using RockMigrations!) add translatable strings to your latte files and make sure to prefix them with either an equal sign or $rf-> or $rockfrontend-> Spoiler <p>{=__('Das ist ein Test')}</p> <p>{=_x('foo bar', 'context')}</p> <p>{=_n('Found one item', 'Found multiple items', 1)}</p> <p>{=_n('Found one item', 'Found multiple items', 2)}</p> <p>{$rf->_('Das ist ein Test')}</p> <p>{$rf->_x('foo bar', 'context')}</p> <p>{$rf->_n('Found one item', 'Found multiple items', 1)}</p> <p>{$rf->_n('Found one item', 'Found multiple items', 2)}</p> <p>{$rockfrontend->_('Das ist ein Test')}</p> <p>{$rockfrontend->_x('foo bar', 'context')}</p> <p>{$rockfrontend->_n('Found one item', 'Found multiple items', 1)}</p> <p>{$rockfrontend->_n('Found one item', 'Found multiple items', 2)}</p> 2 Link to comment Share on other sites More sharing options...
bernhard Posted October 11 Author Share Posted October 11 Hey @Sanyaissues thx for liking this post just in the right time! As of now we don't need any custom syntax any more for translatable strings in Latte files 😎 That's a side-effect of a recent request by @FireWire to make all native PW functions like wire() available in latte files and that also means that __(...) and _n(...) are now natively available in latte files as well! Just use <h1>{__('This is a translatable headline')}</h1> 🥳 Link to comment Share on other sites More sharing options...
Sanyaissues Posted October 11 Share Posted October 11 Thanks for the message @bernhard! By any chance, have you ever used Functional Fields + RF + Latte? I noticed that when I declare __text('foo') directly in home.latte, the functional field doesn't recognize it. However, when I add it to _rockfrontend.php, it works. Link to comment Share on other sites More sharing options...
bernhard Posted October 11 Author Share Posted October 11 No, sorry, maybe {$wire->__text('foo')} works? Link to comment Share on other sites More sharing options...
Sanyaissues Posted October 12 Share Posted October 12 {\ProcessWire\__text('foo')} works (but it didn't solve my problem hahaha). But guess whose module did the trick Spoiler $rm->migrate([ 'fields' => [ 'textlist' => [ 'label' => 'textList', 'fileMode' => 1, 'translateFiles' => [ 0 => './pages/home.latte', //Magic! ], 'type' => 'FieldtypeFunctional', ], ], (…) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now