Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

{ "Phrase text" : "", "var_name" : "Phrase text", "Phrase text" :
Code Block
languagephpactionscript3
themeMidnight
titlephrase.json
linenumberstrue
php

{ 
                                   "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
languagephpactionscript3
titleEasiest define
linenumberstrue
php

{ 
     "Manage Video" : "" 
}

Use:

Code Block
languagephp
php
titleEasiest define - Using
linenumberstrue

<?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
languagephpactionscript3
titleVar name define
linenumberstrue
php

{ 
     "manage_video" : "Manage Video" 
}

...

Usage

Code Block
languagephp
php
titleVar name define - Using
linenumberstrue

<?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
languageactionscript3
titleMulti-language define
linenumberstrue
{ 
	"Phrase text" : { 
                     	"en" : "", 
                        "es" : "Spanish Phrase text", 
                        "ot" : "Other language phrase text" 
                    }, 
} 

 

Use:

 

Code Block
languagephp
titleMulti-language define - Using
linenumberstrue
<?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
languageactionscript3
titleVar name multi-language define
linenumberstrue
{ 
	"phrase_text" : { 
                     	"en" : "Phrase text", 
                        "es" : "Spanish Phrase text", 
                        "ot" : "Other language phrase text" 
                    }, 
} 

 

Use:

 

Code Block
languagephp
titleVar name multi-language define - Using
linenumberstrue
<?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

Default

Code Block
languagephp
titleuse _p
<?php
_p('var_name', $attr)

Smarty

Code Block
languagexml
titlesmarty _p


// print Manage Video
Code Block
php
php

<?php
_p('var_name', $attr);

Within phpFox template .html.php file:

Code Block
php
php

{_p var="var_name" $attr}

...


Within phpFox template *.html file:

Code Block
Code Block
languagexml
titleTwig
linenumberstrue
languagephpxml
titlesmarty _p
{_p var="var_name" $attr}

Twig

php

{{ _p("var_name", $arrt) }}

...

Within JavaScript file

Code Block
languagephpjs
linenumberstrue
php

oTranslations['var_name', arrtcontext]

With $arrt is array of variable on phrase.

3. Use Phrase with variable

The variable can be included in a phrase. Example:

Code Block
languageactionscript3
linenumberstrue
{
	

Translate a phrase with context variables

Code Block
php
php

{
    "total_people_liked_this_blog" : "{total} people liked this blog
}

Use:Usage

Code Block
languagephpactionscript3
linenumberstrue
php

<?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.