Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Requires:

  • phpFox 4.5+

All phrases that used on your apps should be defined before using. The below instructions will help you:

How to to define?

Add file phrase.json on root path of your apps.

Example:

phrase.json
{ 
     "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:

  • The easiest way: Put phrase on key, put blank on value (of json).

Example:

Easiest define
{ 
     "Manage Video" : "" 
} 

Use:

Easiest define - Using
<?php
echo _p("Manage Video"); 

It will show: Manage Video

  • Var_name define: Put var_name on key, put phrase on value (of json).

Example:

Var name define
{ 
     "manage_video" : "Manage Video" 
} 

Use:

Var name define - Using
<?php
echo _p("manage_video"); 

It will show: Manage Video

 

With first and second way, we will use phrase "Manage Video" for all available languages on your site.

  • Easy Multi-language define:

Example:

Multi-language define
{ 
	"Phrase text" : { 
                     	"en" : "", 
                        "es" : "Spanish Phrase text", 
                        "ot" : "Other language phrase text" 
                    }, 
} 

 Use:

Multi-language define - Using
<?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 user is es)

...

  • Var name multi-language define:

Example:

Var name multi-language define
{ 
	"phrase_text" : { 
                     	"en" : "Phrase text", 
                        "es" : "Spanish Phrase text", 
                        "ot" : "Other language phrase text" 
                    }, 
} 

Use:

Var name multi-language define - Using
<?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)

....

How to use

General:

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

Smarty:

smarty _p
{_p var="var_name" $attr}

Twig

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

Javascript

oTranslations['var_name', arrt]

With $arrt is variables of phrase.

Use Phrase with variable

The variables can be included in a phrase. Example:

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

Use:

<?php
echo _p("total_people_liked_this_blog", ["total" => 5]);

It will show: 5 people liked this blog

Note: Use single sign and for variable.

  • No labels