-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for translations in LATTE files
- Loading branch information
1 parent
12fa350
commit 5656765
Showing
3 changed files
with
84 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php // no namespace! | ||
|
||
/** | ||
* Add global translation functions to LATTE files | ||
* In LATTE files use this syntax to add translations: | ||
* {=__('your string')} | ||
* {=_x('your string', 'context)} | ||
* {=_n('found one item', 'fount multiple items', $num)} | ||
*/ | ||
|
||
use function ProcessWire\wire; | ||
|
||
function __($str) | ||
{ | ||
$rf = wire()->modules->get('RockFrontend'); | ||
return \ProcessWire\__($str, $rf->textdomain()); | ||
} | ||
function _x($str, $context) | ||
{ | ||
$rf = wire()->modules->get('RockFrontend'); | ||
return \ProcessWire\_x($str, $context, $rf->textdomain()); | ||
} | ||
function _n($textsingular, $textplural, $count) | ||
{ | ||
$rf = wire()->modules->get('RockFrontend'); | ||
return \ProcessWire\_n($textsingular, $textplural, $count, $rf->textdomain()); | ||
} |