Some Note about Phrases System from 4.5.0
...
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:
Code Block | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||
{ "PhraseVar textName" : "", "var_name" : "PhraseMessage textText", "Phrase text" : { "en" : "", "es" : "Spanish Phrase text", "ot" : "Other language phrase text" }, "var_name" :} |
There are 2 ways to define translation:
The easiest way
Put phrase on key, put blank on value (of json).
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
{ "en""Manage Video" : "Phrase text", "es" : "Spanish Phrase text", "ot" : "Other language phrase text" }, } |
We have 4 ways to define a phrase:
...
}
|
Use:
Code Block | ||||
---|---|---|---|---|
| ||||
<?php
echo _p("Manage Video");
// print Manage Video
|
var_name define:
Put var_name on key, put phrase on value (of json).
Example:
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
{ "Manage Videomanage_video" : "Manage Video" } |
...
Usage
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?php echo _p("manage_video"); // print Manage Video"); |
It will show: Manage Video
- Var name define: Put var_name on key, put phrase on value (of json).
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
|
Code Block | ||||
---|---|---|---|---|
| ||||
<?php
_p('var_name', $attr);
|
Within phpFox template .html.php file:
Code Block | ||||
---|---|---|---|---|
| ||||
{_p var="var_name" $attr}
|
Within phpFox template *.html file:
Code Block | ||||
---|---|---|---|---|
| ||||
{{ _p("var_name", $arrt) }}
|
Within JavaScript file
Code Block | ||||
---|---|---|---|---|
| ||||
oTranslations['var_name', context]
|
Translate a phrase with context variables
Code Block | ||||
---|---|---|---|---|
| ||||
{ "manage_videototal_people_liked_this_blog" : "Manage Video" {total} people liked this blog } |
...
Usage
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?php echo _p("manage_video"); |
It will show: Manage Video
total_people_liked_this_blog", ["total" => 5]);
|
Result: 5 people liked this blog
Info |
---|
Use single sign { and } for variable. |