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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| {
"Phrase text" : "",
"var_name" : "Phrase text",
"Phrase text" :
| |||||||||||
{ "en" : "", "es" : "Spanish Phrase text"Var Name" : "", "ot" : "Other language phrase text" }, "var_name" : { "en" : "Phrase text", "es" : "Spanish Phrase text", "ot" : "Other language phrase text" }, } |
We have 4 ways to define a phrase:
...
"Message Text"
}
|
There are 2 ways to define translation:
The easiest way
Put phrase on key, put blank on value (of json).
Example:
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
{
"Manage Video" : ""
}
|
Use:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?php echo _p("Manage Video"); |
It will show: Manage Video
...
// print Manage Video
|
var_name define:
Put var_name on key, put phrase on value (of json).
Example:
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
{
"manage_video" : "Manage Video"
}
|
...
Usage
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?php echo _p("manage_video"); |
It will show: Manage Video
Info |
---|
With way 1 and 2, we will use "Manage Video for all available language on your site. |
- Easy Multi-language define: Define multi language for your phrase
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{
"Phrase text" : {
"en" : "",
"es" : "Spanish Phrase text",
"ot" : "Other language phrase text"
},
} |
Use:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?php
echo _p("Phrase text"); |
"en": can be missed
Clients' site have to installed language package with id "es", if not, es phrase will by pass. It's the same for other language package.
It will show: Phrase text (if default language of user is en)
It will show: Spanish Phrase text (If default language of users is es)
...
- Var name multi-language define:
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{
"phrase_text" : {
"en" : "Phrase text",
"es" : "Spanish Phrase text",
"ot" : "Other language phrase text"
},
} |
Use:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// print Manage Video
|
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 | ||||
---|---|---|---|---|
| ||||
{
"total_people_liked_this_blog" : "{total} people liked this blog
}
|
Usage
Code Block | ||||
---|---|---|---|---|
| ||||
<?php echo _p("phrase_text"); |
"en": is required (can not be missed)
Clients' site have to installed language package with id "es", if not, es phrase will by pass. It's the same for other language package.
It will show: Phrase text (if default language of user is en)
It will show: Spanish Phrase text (If default language of users is es)
....
2. How to use
total_people_liked_this_blog", ["total" => 5]);
|
Result: 5 people liked this blog
Info |
---|
Use single sign { and } for variable. |