Download the PHP package charlemagne/shuwa without Composer

On this page you can find all versions of the php package charlemagne/shuwa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package shuwa

charlemagne/shuwa

Disclaimer: This project has education purpose only. Consider buying the Official Google Translate API.

v1.2.1 Features

  • Implementing the request timeout to prevent blocking requests.
  • Auto-detect source language.
  • Detect language from a quote function.
  • Bug fixes.

Notes: this feature break the backward compatibility due to the constructor edit. Despite this, it won't require a brand new version, so please read the new documentation about the constructor.


Documentation


Requirements

This project require:

  • php 7.*
  • Composer

Package used:

  • Fabpot \ Goutte

Installation

Run the command below to install the package:

Or just create a composer.json file as it follow:

And then run:


Usage

Shuwa class

Require Composer autoloader into your working file and use Shuwa class:

Create a Shuwa object:

Here's a list of all language codes (Please use the ISO 639-1 Code version).

Quick list of all basic functions:

FShuwa class

use FShuwa class as it follows:

Create an FShuwa object:

FShuwa class extends Shuwa, so you can basically use all of Shuwa's methods. There are few more methods that helps you to translate a whole Laravel\CodeIgniter Language file, but it could take hours. Here's a list of all FShuwa's methods:

Options

You can modify Shuwa and FShuwa class options by editing the vendor\charlemagne\shuwa\src\config\shuwa.php file. Let's take a look:

Shuwa class options

Enable the safe mode while creating the object.

'SAFE_MODE' => true,

Set timeout seconds to the requests (Preventing a deadlock).

'REQUEST_TIMEOUT' => 15,

FShuwa class options

If you want to keep a word in native language while translating a file, you should use the target option. Example [EN -> IT]: 'I bought :number apples'; If you set the target as ':', then the translated quote will be: 'Ho comprato :number mele'; But remember that it can fail. If so, the algorithm will return the untranslated quote

'TARGET' => ':',

If you want to keep HTML quotes untraslated, keep the follow option to true.

'HTML_INTEGRITY' => true,

If you want to single words quotes untraslated, keep the follow option to true.

'MANTAIN_SINGLE_WORDS' => true,

If you want to ban some words, so the translation doesn't affects the quotes that containts them, then add those words in the blacklist:

'BLACKLIST' => [ 'lorem', 'ipsum', 'docet'
]


SafeMode

There is a percentage of risk that you get temporary ip-banned from Google, because of Too Many Requests. Both to prevent and cure this issue, you can run the safe mode.

I suppose that you don't use my package for mass translation, so I unset the safemode by default, but you can modify the default settings in vendor/charlemagne/shuwa/src/config/shuwa.php, just set SAFE_MODE = true.

This will slow down by 1 minute or less your script, if you want to know why, read the Proxy System section.

You can set the safe mode inside your code by using this function:

When you get ip-banned, Shuwa automatically run the safe mode to get its work done.


ProxySystem

ProxySys class protect you from Google IP ban, but slow down a lot the process. If you want to quickly translate few quotes (< 20), I recommend you to disable SAFE_MODE.

Usage

Use the class as it follows:

Here's a list of ProxySys' methods:

Options

You can modify ProxySys class options by editing the vendor\charlemagne\shuwa\src\config\proxy.php file. Let's take a look:

Enable https on supportSource function when Scrape() doesn't works.

'RESERVE_SSL' => true,

Time To Live of the TEST requests made to the TEST_URL server, we need to set an optimal number to ensure that the filter() function mantain only the working proxyes

'TTL' => 1000,

Proxyes list dimension limit

'LIST_LIMIT' => 100

Scrape the proxy list when the class is instantiated

'AUTO_SCRAPE' => true,

Filter the proxy list when the class is instantiated

'AUTO_FILTER' => true,

Optimize the proxy list when the class is instantiated

'AUTO_OPTIMIZE' => true,

Fitler the proxy list on reload

'FILTER_ON_RELOAD' => true,

Optimize the proxy list on reload

'OPTIMIZE_ON_RELOAD' => true,

Print proxySys actions, helpful while executing through terminal

'DYSPLAY' => [ 'SET' => true ]


Donate

if you appreciate my work and want to offer me a coffee, feel free to do so! :)

Paypal: https://www.paypal.me/charlemgn



All versions of shuwa with dependencies

PHP Build Version
Package Version
Requires fabpot/goutte Version ^3.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package charlemagne/shuwa contains the following files

Loading the files please wait ....