...
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" }, } |
...
"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 first and second way, we will use phrase "Manage Video" for all available languages on your site. |
- Easy Multi-language define:
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
Info |
---|
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 user 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 | ||||||
---|---|---|---|---|---|---|
| ||||||
<?php
echo _p("phrase_text"); |
"en": is required (can not be missed)
Info |
---|
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)
....
How to use
General:
Code Block | ||||
---|---|---|---|---|
| ||||
<?php _p(' // 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', arrtcontext] |
With $arrt is variables of phrase.
Use Phrase with variable
...
|
Translate a phrase with context variables
Code Block | |||||||
---|---|---|---|---|---|---|---|
| |||||||
{ "total_people_liked_this_blog" : "{total} people liked this blog } |
Use:Usage
Code Block | |||||||
---|---|---|---|---|---|---|---|
| |||||||
<?php echo _p("total_people_liked_this_blog", ["total" => 5]); |
It will showResult: 5 people liked this blogNote:
Info |
---|
Use single |
...
sign { |
...
and } |
...
for variable. |