azbox/azbox-php
Composer 安装命令:
composer require azbox/azbox-php
包简介
The library to integrate Azbox translation to PHP
README 文档
README
The library to integrate Azbox translation to a PHP website
Getting Started
Install
Install the package via Composer:
composer require azbox/azbox-php
(If you don't use Composer, you can copy the azbox.php file and the lib directory to your project).
Initialize
To initialize Azbox, you need your API Key. You can find it on your Azbox account.
Enter Azbox initialization code at the beginning of the execution (Usually index.php or app.php)
// composer autoload require __DIR__ . '/vendor/autoload.php'; // if you are not using composer: require_once 'path/to/azbox.php'; \Azbox\WG::Instance(array( "api_key" =>"YOUR API KEY", // The api key, you can get one on https://panel.azbox.io/register "original_l" =>"en", // the original language of your website "destination_l" =>"fr,de", // the languages you want to translate your website into ));
Check it works !
Now, when you go on your website, you should see a country selector with flags at the bottom right of your website.
Customize
Button position
By default, the language button appears as fixed, at the bottom right of your website.
But you can make it appear wherever you want in your HTML page. Just enter <div id="azbox_here"></div> in your HTML wherever you want the button to be.
You can also customize it by adding some CSS rules on the button's element.
Parameters
Required
api_keyA string that gives you access to Azbox sevices. You can get one by creating an accountoriginal_lThe language of your original website. Enter the two letter code. The list of code is available heredestination_lThe languages you want to translate into. Enter the two letter codes separated by commas.
Optional
-
buttonOptions(array) An array of paramters to customize the language button designis_dropdown(bool, defaulttrue)trueif the button is a dropdown list,falseto show all languages as a listwith_name(bool, defaulttrue)trueto show the name of the language in the buttonfullname(bool, defaulttrue)trueto show the full name of the language in the button (English, Français,...) ,falseto show the language code (EN, FR,...)with_flags(bool, defaulttrue)trueto show the flags,falseto not show flagstype_flags(int, default0) The design of the flags0rectangular mate1rectangular bright2square3circle
-
exclude_blocks(string, default "") : comma separated list of CSS selectors. You can exclude part of your website from being translated. -
exclude_url(string, default "") : comma separated list of relative URLs. You can exclude URL of your website from being translated. -
home_url(string, default "") : Enter the subdirectory if your website is not at the root. For instance, if your website is athttp://localhost/website/, then enter/website
Example
Here is an example of initialization code
// Example : Your website is in French, and you want it also in English, German, Japanese new \Azbox\WG(array( "api_key" =>"YOUR API KEY", // The api key, you can get one on https://panel.azbox.io/register "original_l" =>"fr", "destination_l" =>"en,de,ja", "buttonOptions" => array("fullname"=>false,"with_name"=>true,"is_dropdown"=>false,"with_flags"=>true,"type_flags"=>1), "exclude_blocks" => ".logo,nav #brand" "exclude_url" => "/terms-conditions,/privacy-policy" ));
Troubleshooting
Once you save the initialization code, you should see the language button appear at the bottom right of your website.
If that is not the case, it means the Azbox code is not running. Check if you have PHP errors
If you see the flags but when you switch languages, you see a 404 /Not found, it means Azbox code is not running or not at the beginning. Azbox needs to run before the request is processed so make sure it is included at the beginning of the PHP code.
Also, make sure that your rewrite rules are configured so that the PHP code is run on a 404 page.
And of course, finally, contact us at support@azbox.io or on the live chat on our website, we answer pretty fast :)
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-01-07