Some Notes about Phrase System from 4.5.0
- Deprecating function: Phpfox::getPhrase. On version 4.5.0, you can use this function, but it will be removed completely from 4.6.0.
- Have to define phrase before use.
- Define and use:
How to to define:
Add file phrase.json on root path of your apps.
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
{ "Phrase text" : "", "var_name" : "Phrase text", "Phrase text" : { "en" : "", "es" : "Spanish Phrase text", "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:
- Easiest defineThe easiest way: Put phrase on key, put blank on value (of json).
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{ "Manage Video" : "" } |
...
- Var_name define: Put var_name on key, put phrase on value (of json).
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{ "manage_video" : "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"); |
...
- Var name multi-language define:
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{ "phrase_text" : { "en" : "Phrase text", "es" : "Spanish Phrase text", "ot" : "Other language phrase text" }, } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?php echo _p("phrase_text"); |
"en": is required (can not be missed)
...
It will show: Spanish Phrase text (If default language of users is es)
....
...
How to use
General:
Code Block | ||||
---|---|---|---|---|
| ||||
<?php _p('var_name', $attr) |
...
With $arrt is variables of phrase.
...
Use Phrase with variable
The variables can be included in a phrase. Example:
...