承接 azbox/azbox-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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_key A string that gives you access to Azbox sevices. You can get one by creating an account
  • original_l The language of your original website. Enter the two letter code. The list of code is available here
  • destination_l The 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 design

    • is_dropdown (bool, default true) true if the button is a dropdown list, false to show all languages as a list
    • with_name (bool, default true) true to show the name of the language in the button
    • fullname (bool, default true) true to show the full name of the language in the button (English, Français,...) , false to show the language code (EN, FR,...)
    • with_flags (bool, default true) true to show the flags, false to not show flags
    • type_flags (int, default 0) The design of the flags
    • 0 rectangular mate
    • 1 rectangular bright
    • 2 square
    • 3 circle
  • 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 at http://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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-07