All phrases that used on your apps should be defined before using. The below instructions will help you:
How to to define?
Add a phrase.json file on under your app directory, this file contains all phrase in your app.
Example:
{ "Var Name" : "", "var_name" : "Message Text" } |
There are 2 ways to define translation:
Put phrase on key, put blank on value (of json).
Example:
{ "Manage Video" : "" } |
Use:
<?php echo _p("Manage Video"); // print Manage Video |
Put var_name on key, put phrase on value (of json).
Example:
{ "manage_video" : "Manage Video" } |
Usage
<?php echo _p("manage_video"); // print Manage Video |
<?php _p('var_name', $attr); |
Within phpFox template .html.php file:
{_p var="var_name" $attr} |
Within phpFox template *.html file:
{{ _p("var_name", $arrt) }} |
Within JavaScript file
oTranslations['var_name', arrt] |
Translate a phrase with context variables
Use Phrase with variable
The variables can be included in a phrase. Example:
{ "total_people_liked_this_blog" : "{total} people liked this blog } |
Usage
<?php echo _p("total_people_liked_this_blog", ["total" => 5]); |
Result: 5 people liked this blog
Use single sign { and } for variable.