LaravelのためのGoogle Cloud AI API翻訳とGoogle翻訳の実装

電子機器、モノクロ
目次

Laravelベースのウェブサイトを所有している方にとって、正確で自然な翻訳コンテンツを提供することは、ウェブサイトを翻訳することと良好なユーザーエクスペリエンスを提供するために非常に重要です。

幸いなことに、Google Cloud AI API Translation や Google Translate など、開発者がこの課題を克服するのに役立つ自動翻訳サービスがいくつかあります。どちらのサービスも、機械翻訳技術を使用して翻訳機能を提供します。.

この記事では、LaravelアプリケーションにGoogle Cloud AI TranslationGoogle翻訳Laravelウェブサイトに最適な翻訳サービスをお勧めします。

Google Cloud AI API翻訳とGoogle翻訳とは何ですか?

議論に入る前に、Google Cloud AI APIとGoogle翻訳のそれぞれの意味について説明します.

Google Cloud AI API翻訳

Google Cloudサーバーとクラウドストレージ

Google Cloud AI API Translation は、Google Cloud Platform が提供する高度な自動翻訳サービスです。このサービスは、最新の人工知能(AI)と機械学習技術を活用して、テキスト、音声、ドキュメントの正確で自然な翻訳を提供します。

Google Cloud AI API翻訳は、ディープラーニングに基づくニューラル翻訳モデルを使用しており、言語のニュアンスや文脈をよりよく捉えることができ、実際の言語使用に合わせたより慣用的な翻訳を提供します。さらに、Google Cloud AI翻訳を最大50万文字まで無料で利用でき、次の7万5千文字は100万文字あたり20ドルの費用がかかります。. 

Google翻訳

翻訳設定インターフェイス。言語設定オプション。.

一方、Google翻訳は長年広く知られている自動テキスト翻訳サービスです。より伝統的な統計的翻訳アプローチを使用しており、大量のトレーニングデータセットから学習したパターンと確率に基づいて翻訳を生成します。.

正確さや言語のニュアンスの扱いにおいて Google Cloud AI API Translation ほど高度ではありませんが、Google Translate は使いやすさと非商用利用での無料提供により人気のある選択肢です。.

Laravel で Google Cloud AI API 翻訳を実装する

いくつかの翻訳サービス(Linguiseを含む)は、AI翻訳クラウド技術を使用してウェブサイトを翻訳します。

言語翻訳サービスは、クラウドAI APIを翻訳技術の1つとして使用しています。以下は、Laravelウェブサイトでの実装手順です。ここでは、すでに準備ができているLaravelプロジェクトのウェブサイトをお持ちであると仮定します。

Linguise アカウントの作成

Linguiseアカウントを登録する必要があります。無料で登録するか、1 か月または 1 年間サブスクライブすることができます。メールアドレス、ユーザー名、パスワードなどの情報のみ提供する必要があります。

Laravel ウェブサイト情報の追加

その後、使用するウェブサイトに関する情報を追加し、 Linguise アカウント情報とWeb URLを入力し、 Laravel プラットフォームを選択し、デフォルトの言語とウェブサイトに追加する言語を追加します。.

 

ローディングアニメーション

以下のボタンをクリックして PHP スクリプトをダウンロードし、ローカルコンピュータに保存してください。.

PHPスクリプトのアップロードと設定

スクリプトをダウンロードした後、解凍して Laravel がインストールされているルートフォルダにアップロードします。 Laravel インストールのルート(通常はCMSファイルがある場所)に配置されていることを確認してください。フォルダ名が「linguise」(フォルダを解凍したときのデフォルト名)であることを確認してください。.

コンピュータファイルシステムのナビゲーションメニュー

次に、 Linguise APIキーを、サーバーにアップロードした…/linguise/Configuration.phpファイルにコピーする必要があります。ファイルを編集し、APIキーを引用符の間に貼り付け、REPLACE_BY_YOUR_TOKENテキストを置き換えます。.

コード設定のスクリーンショット

言語切り替えスクリプトの挿入

スクリプト言語スイッチャー - Google Cloud AI API翻訳とGoogle翻訳の実装比較 Laravel

resources/views/layouts/ ディレクトリの front.blade.php ファイルに挿入します。挿入されたスクリプトのプレビューはこちらです。.

コード出力を表示するターミナルウィンドウ

.htaccessの設定

最後に、言語ベースのURLを.htaccessファイルで設定する必要があります。ファイルに「RewriteBase /」が含まれている場合は、その行の後に次のコードをコピーして貼り付けてください。.

				
					<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-cn|zh-tw|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu|zz-zz)(?:$|/)(.*)$ linguise/linguise.php?linguise_language=$1&original_url=$2 [L,QSA]
</IfModule>
				
			

完了しました。この時点で、Linguise サービスでクラウドAI API翻訳が正常に実装されました。次に、Laravel ウェブサイトを確認できます。デフォルトの言語切り替えが表示され、ダッシュボード経由でLaravel 用の言語切り替えをカスタマイズできます。

暗い背景の男性、不気味な雰囲気

LaravelでGoogle翻訳を実装する

ここでは、 LaravelでGoogle翻訳を実装してみます。ここでは、 Laravel プロジェクトが正常に作成されたと仮定し、Google翻訳を追加するだけです。.

以下のインストール手順は、公式Laravelウェブサイトでも確認できます。

Google翻訳パッケージのインストール

Google翻訳パッケージをインストールするには、プロジェクトプロンプトを開き、次のコマンドを入力します。このパッケージを使用すると、google-translator-languageの作業機能を利用できます。.

				
					composer require stichoza/google-translate-php
				
			

Google翻訳パッケージの設定

アプリケーション内に「google translator package」を設定する必要があります。/config フォルダーの app.php ファイルを開き、「aliases」セクションを見つけて、次のコード行を追加します。.

画面にコードテキストが表示されたコンピュータ端末。ディスプレイにはさまざまなコード行が表示されます。.
				
					/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => Facade::defaultAliases()->merge([
    // 'Example' => App\Facades\Example::class,
    'GoogleTranslate' => Stichoza\GoogleTranslate\GoogleTranslate::class,
])->toArray(),

				
			

言語コントローラーの設定

以下のような言語コントローラーファイルを作成する必要があります

				
					php artisan make:controller LangController
				
			

/app/Http/Controllersフォルダ内にLangController.phpファイルが作成されます。.

コード行を表示するコンピュータ画面
				
					<?php

namespace App\Http\Controllers;

use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;

class LangController extends Controller
{
    public function index(): View
    {
        return view('lang');
    }

    public function change(Request $request)
    {
        App::setLocale($request->lang);
        
        session()->put('locale', $request->lang);

        return redirect()->back();
    }
}


				
			

ブレードテンプレートファイルの作成

/resources/viewsフォルダに移動し、lang.blade.phpという名前のファイルを作成します。ファイルを編集し、次のコードを挿入してください。.

コンピューターの画面上のコードの画像。プログラミングテキスト。.
				
					<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laravel 10 Create Multi Language Website Tutorial</title> <script type="litespeed/javascript" data-src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script type="application/ld+json" class="gnpub-schema-markup-output">{"@context":"https:\/\/schema.org\/","@type":"NewsArticle","@id":"https:\/\/www.linguise.com\/blog\/guide\/implement-google-cloud-ai-api-translation-vs-google-translate-for-laravel\/#newsarticle","url":"https:\/\/www.linguise.com\/blog\/guide\/implement-google-cloud-ai-api-translation-vs-google-translate-for-laravel\/","image":{"@type":"ImageObject","url":"https:\/\/www.linguise.com\/wp-content\/uploads\/2024\/05\/Implement-Google-Cloud-AI-API-translation-vs-Google-Translate-for-Laravel-150x150.png","width":150,"height":150},"headline":"Implement Google Cloud AI API translation vs Google Translate for Laravel","mainEntityOfPage":"https:\/\/www.linguise.com\/blog\/guide\/implement-google-cloud-ai-api-translation-vs-google-translate-for-laravel\/","datePublished":"2024-05-31T07:32:47+00:00","dateModified":"2024-08-26T19:19:15+00:00","description":"For those of you who own Laravel-based websites, providing accurate and natural translation content is very important to translate your website and offer a good","articleSection":"Guide","articleBody":"For those of you who own Laravel-based websites, providing accurate and natural translation content is very important to translate your website and offer a good user experience.\nFortunately, several automatic translation services are available to help developers overcome this challenge, including Google Cloud AI API Translation and Google Translate. Both services offer translation capabilities using machine technology.\nIn this article, we will explore the main differences between implementing Google Cloud AI Translation and Google Translate for Laravel applications and recommend the best translation services for your Laravel website.&nbsp;\t\t\n\t\t\tWhat are Google Cloud AI API translation &amp; Google Translate?\n\t\t\n\t\tBefore entering into the discussion, we will discuss the respective meanings of Google Cloud AI API and Google Translate translations.\t\t\n\t\t\tGoogle Cloud AI API translation\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tGoogle Cloud AI API Translation is an advanced automatic translation service provided by Google Cloud Platform. This service leverages the latest artificial intelligence (AI) and machine learning technologies to deliver accurate and natural translations of text, voice, and documents.Google Cloud AI API Translation uses neural translation models based on deep learning, which allows it to capture language nuances and context better, providing more idiomatic translations that align with actual language usage. Additionally, using Google Cloud AI Translation for up to 500,000 characters is free of charge, while the next 75,000 characters will incur a cost of $20 per million characters.\u00a0\t\t\n\t\t\tGoogle Translate\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tMeanwhile, Google Translate is a long-standing and widely known automatic text translation service. It uses a more traditional statistical translation approach, which generates translations based on patterns and probabilities learned from large training datasets.Although it is not as advanced as Google Cloud AI API Translation in terms of accuracy and handling language nuances, Google Translate remains a popular choice due to its ease of use and free availability for non-commercial use.\t\t\n\t\t\tImplement Google Cloud AI API translation on Laravel\n\t\t\n\t\tSeveral translation services, including Linguise, use AI Translation cloud technology to translate websites.The language translation service uses cloud AI API as one of its translation technologies. The following are the implementation steps on the Laravel website. We assume here that you already have a ready Laravel project website.\t\t\n\t\t\tCreate Linguise account\n\t\t\n\t\tTo use Linguise, you must register an account first. You can do this for free or subscribe for one month or a year. You only need to provide information such as your email, username, and password.\t\t\n\t\t\tAdd Laravel website info\n\t\t\n\t\tAfter that, add information about the website you will use, enter your Linguise account info and web URL, select the Laravel platform, and add the default language and the language you want to add to the website.\u00a0\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tThen download the PHP script via the following button and save it on your local computer.\t\t\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tDOWNLOAD PHP-JS TRANSLATION SCRIPT\n\t\t\t\t\t\n\t\t\tUpload and configure the PHP script\n\t\t\n\t\tAfter downloading the script, unzip it and upload it to the root folder where Laravel is installed. Ensure it is located at the root of your Laravel installation (typically where your CMS files are). Ensure the folder is named \"linguise\" (the default name when the folder is unzipped).\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tThen, the Linguise API key must be copied into the \u2026\/linguise\/Configuration.php file you uploaded to your server. Edit the file and paste your API key between the quotes, replacing the text REPLACE_BY_YOUR_TOKEN.\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tInsert script of language switcher\t\t\n\t\tNext, insert the language switch script that you got from the Linguise dashboard.\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tInserted into the front.blade.php file in the resources\/views\/layouts\/ directory. Here is a preview of the inserted script.\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tConfigure .htaccess\n\t\t\n\t\tLastly, language-based URLs need to be configured in the .htaccess file. If your file includes \"RewriteBase \/,\" simply copy and paste the following code after that line.\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n  RewriteEngine On\n  RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-cn|zh-tw|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu|zz-zz)(?:$|\/)(.*)$ linguise\/linguise.php?linguise_language=$1&original_url=$2 [L,QSA]\n\n\t\t\t\t\n\t\t\t\n\t\tDone. At this point, you have successfully implemented cloud AI API Translation on the Linguise service. Now, you can check the Laravel website. A default language switcher will appear, and you can customize the Language switcher for Laravel via the dashboard.\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tImplement Google Translate on Laravel\t\t\n\t\tNow we will try to implement Google Translate in Laravel. Here we assume that you have successfully created a Laravel project and just need to add Google Translate.You can also find the following installation steps on the official Laravel website.\t\t\n\t\t\tInstall Google Translator Package\n\t\t\n\t\tTo install the Google Translator Package, open the project prompt and input the following command. This package will enable you to utilize the working functions of the google-translator-language.\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\tcomposer require stichoza\/google-translate-php\n\t\t\t\t\n\t\t\t\n\t\t\tSetting of Google Translator Package\n\t\t\n\t\tWe must set up the \"google translator package\" within the the application. Open the app.php file in the \/config folder, find the \"aliases\" section, and add the following line of code.\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\/*\n|--------------------------------------------------------------------------\n| Class Aliases\n|--------------------------------------------------------------------------\n|\n| This array of class aliases will be registered when this application\n| is started. However, feel free to register as many as you wish as\n| the aliases are \"lazy\" loaded so they don't hinder performance.\n|\n*\/\n'aliases' => Facade::defaultAliases()->merge([\n    \/\/ 'Example' => AppFacadesExample::class,\n    'GoogleTranslate' => StichozaGoogleTranslateGoogleTranslate::class,\n])->toArray(),\n\n\t\t\t\t\n\t\t\t\n\t\t\tSetup Language Controller\n\t\t\n\t\tYou need to create a language controller file like the following\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\tphp artisan make:controller LangController\n\t\t\t\t\n\t\t\t\n\t\tIt will create LangController.php file inside \/app\/Http\/Controllers folder.","keywords":"","name":"Implement Google Cloud AI API translation vs Google Translate for Laravel","thumbnailUrl":"https:\/\/www.linguise.com\/wp-content\/uploads\/2024\/05\/Implement-Google-Cloud-AI-API-translation-vs-Google-Translate-for-Laravel-150x150.png","wordCount":809,"timeRequired":"PT3M35S","mainEntity":{"@type":"WebPage","@id":"https:\/\/www.linguise.com\/blog\/guide\/implement-google-cloud-ai-api-translation-vs-google-translate-for-laravel\/"},"author":{"@type":"Person","name":"Tristan","url":"https:\/\/www.linguise.com\/author\/tristan\/","sameAs":[],"image":{"@type":"ImageObject","url":"https:\/\/secure.gravatar.com\/avatar\/50d7238660b192d8d54ebf6367be5e97bb41c24dbd190daae062d931efd351ae?s=96&d=mm&r=g","height":96,"width":96}},"editor":{"@type":"Person","name":"Tristan","url":"https:\/\/www.linguise.com\/author\/tristan\/","sameAs":[],"image":{"@type":"ImageObject","url":"https:\/\/secure.gravatar.com\/avatar\/50d7238660b192d8d54ebf6367be5e97bb41c24dbd190daae062d931efd351ae?s=96&d=mm&r=g","height":96,"width":96}}}</script> </head>

<body>
    <div class="container mt-5">
        <div class="row">
            <div class="col-md-12">
                <div class="card w-75 m-auto">
                    <div class="card-header text-center bg-primary text-white">
                        <h4 style="font-size: 17px;">Laravel 10 Create Multi Language Website Tutorial</h4>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-4">
                                <strong>Select Language: </strong>
                            </div>
                            <div class="col-md-4">
                                <select class="form-select changeLang">
                                    <option value="en" {{ session()->get('locale') == 'en' ? 'selected' : '' }}>
                                        English
                                    </option>
                                    <option value="fr" {{ session()->get('locale') == 'fr' ? 'selected' : '' }}>
                                        French
                                    </option>
                                    <option value="ar" {{ session()->get('locale') == 'ar' ? 'selected' : '' }}>
                                        Arabic
                                    </option>
                                    <option value="hi" {{ session()->get('locale') == 'hi' ? 'selected' : '' }}>
                                        Hindi
                                    </option>
                                </select>
                            </div>
                        </div>

                        <div style="margin-top: 20px;">
                            <p>{{ GoogleTranslate::trans('Welcome to Online Web Tutor', app()->getLocale()) }}</p>
                            <p>{{ GoogleTranslate::trans('It is a passionate and innovative Web Development Community dedicated to empowering aspiring web developers with the latest tools and techniques. Our platform offers a comprehensive range of web development courses, including PHP and its frameworks, Node.js, MySQL, Javascript and WordPress.', app()->getLocale()) }}
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

     <script data-no-optimize="1">var litespeed_vary=document.cookie.replace(/(?:(?:^|.*;\s*)_lscache_vary\s*\=\s*([^;]*).*$)|^.*$/,"");litespeed_vary||fetch("/wp-content/plugins/litespeed-cache/guest.vary.php",{method:"POST",cache:"no-cache",redirect:"follow"}).then(e=>e.json()).then(e=>{console.log(e),e.hasOwnProperty("reload")&&"yes"==e.reload&&(sessionStorage.setItem("litespeed_docref",document.referrer),window.location.reload(!0))});</script><script data-optimized="1" type="litespeed/javascript" data-src="https://www.linguise.com/wp-content/litespeed/js/4efcce905aeba23da8ea1c66b8bc70f0.js?ver=0275f"></script><script>window.litespeed_ui_events=window.litespeed_ui_events||["mouseover","click","keydown","wheel","touchmove","touchstart"];var urlCreator=window.URL||window.webkitURL;function litespeed_load_delayed_js_force(){console.log("[LiteSpeed] Start Load JS Delayed"),litespeed_ui_events.forEach(e=>{window.removeEventListener(e,litespeed_load_delayed_js_force,{passive:!0})}),document.querySelectorAll("iframe[data-litespeed-src]").forEach(e=>{e.setAttribute("src",e.getAttribute("data-litespeed-src"))}),"loading"==document.readyState?window.addEventListener("DOMContentLoaded",litespeed_load_delayed_js):litespeed_load_delayed_js()}litespeed_ui_events.forEach(e=>{window.addEventListener(e,litespeed_load_delayed_js_force,{passive:!0})});async function litespeed_load_delayed_js(){let t=[];for(var d in document.querySelectorAll('script[type="litespeed/javascript"]').forEach(e=>{t.push(e)}),t)await new Promise(e=>litespeed_load_one(t[d],e));document.dispatchEvent(new Event("DOMContentLiteSpeedLoaded")),window.dispatchEvent(new Event("DOMContentLiteSpeedLoaded"))}function litespeed_load_one(t,e){console.log("[LiteSpeed] Load ",t);var d=document.createElement("script");d.addEventListener("load",e),d.addEventListener("error",e),t.getAttributeNames().forEach(e=>{"type"!=e&&d.setAttribute("data-src"==e?"src":e,t.getAttribute(e))});let a=!(d.type="text/javascript");!d.src&&t.textContent&&(d.src=litespeed_inline2src(t.textContent),a=!0),t.after(d),t.remove(),a&&e()}function litespeed_inline2src(t){try{var d=urlCreator.createObjectURL(new Blob([t.replace(/^(?:<!--)?(.*?)(?:-->)?$/gm,"$1")],{type:"text/javascript"}))}catch(e){d="data:text/javascript;base64,"+btoa(t.replace(/^(?:<!--)?(.*?)(?:-->)?$/gm,"$1"))}return d}</script></body>

</html>

				
			

言語ミドルウェアの設定

プロジェクトのターミナルを開いて、このコマンドを実行します。

				
					php artisan make:middleware LanguageManager


				
			

/app/Http/Middlewareフォルダ内にLanguageManager.phpファイルが作成され、これが貼り付けられます。.

白黒のピクセル化された画像。詳細は不明。.
				
					<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\App;

class LanguageManager
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle(Request $request, Closure $next): Response
    {
        if (session()->has('locale')) {

            App::setLocale(session()->get('locale'));
        }

        return $next($request);
    }
}

				
			

Kernel.phpを介して言語ミドルウェアを登録する

/app/Http ディレクトリにある Kernel.php ファイルを開きます。$middlewareGroups 配列を探し、web セクションに移動します。.

黒い背景にテキストのぼやけた画像。テキストは読み取れません。.
				
					/**
 * The application's route middleware groups.
 *
 * @var array<string, array<int, class-string|string>>
 */
protected $middlewareGroups = [
    'web' => [
        
        //...

        \App\Http\Middleware\LanguageManager::class,
    ],

    'api' => [
        
        //...
    ],
];

				
			

ルートを追加

/routesフォルダからweb.phpを開き、これらのルートを追加します。.

Web.php - Google Cloud AI API翻訳とGoogle翻訳の Laravelの実装
				
					//...
use App\Http\Controllers\LangController;

//...

Route::get('lang/home', [LangController::class, 'index']);
Route::get('lang/change', [LangController::class, 'change'])->name('changeLang');


				
			

ウェブサイトのテスト

プロジェクトのターミナルでこのコマンドを実行して、開発サーバーを起動します。.

				
					php artisan serve
				
			

以下は、ウェブサイト Laravel の表示例です。onlinewebtutorblog.com が作成したもので、次の表示で Google Translate のドロップダウンがあることがわかります。

コンピュータ画面と思われる画像が歪んでいる。.

このように、 Laravel のウェブサイトをアラビア語に翻訳すると、このようになります。.

故障したコンピューター画面。歪んだコードとテキストが表示される。.

Google Cloud AI翻訳と Laravel上のGoogle翻訳の実装の違いは何ですか?

Google Cloud AIとGoogle翻訳の各実装を Laravelで理解した後、それらの違いについて説明します。.

インストールと設定プロセス

白黒のイラスト。大きなターゲットの近くに立つ人々。.
  • Google Cloud AI API翻訳: インストールと設定のプロセスはより複雑です。Google Cloud Platform(GCP)でプロジェクトを作成し、Cloud Translation APIを有効にし、サービスアカウントを作成し、APIキーを生成し、Laravel
  • Google翻訳: インストールと設定は非常に簡単です。Composer経由でstichoza/google-translate-phpなどのサードパーティパッケージまたはライブラリをインストールするだけで済みます。その後、Laravel設定ファイルでGoogle翻訳APIキーを設定できます。

翻訳の正確さ

コンピューターの周りに集まった人々のグループ.
  • Google Cloud AI API翻訳:ディープラーニング機能により、複雑な言語の文脈やニュアンスをよりよく捉えることができます。これにより、慣用句、比喩的表現、言葉遊びなどの翻訳がより正確になります。
  • Google翻訳:は、微妙な言語の文脈やニュアンスを捉えるのに苦労することが多く、結果が硬い、または不自然に聞こえることがあります。統計的なアプローチにより、慣用句や比喩的な表現の翻訳は、正確性に欠けることがよくあります。

応答速度

ノートパソコンと携帯電話から離陸するロケット船。.
  • Google Cloud AI API 翻訳: 最適化された ニューラル機械翻訳 モデルを Google の堅牢なクラウドインフラストラクチャでホストしているため、翻訳リクエストへの対応が通常より速くなります。これにより、長いテキストや大量の翻訳の場合に、迅速なレスポンスタイムが提供されます。
  • Google翻訳: 翻訳リクエストへの対応がわずかに遅くなる可能性があります。特に長いドキュメントやテキストの場合、これはGoogle Cloud AI API翻訳で使用されるニューラルモデルほど効率的ではない、より伝統的な統計的およびニューラル翻訳アプローチの混合を使用しているためです。

カスタマイズと制御機能

グリッチ効果のある歪んだコンピューター画面。画像は破損しているようです。.
  • Google Cloud AI API翻訳: 翻訳プロセスをカスタマイズおよび制御するためのより多くのオプションを提供します。たとえば、翻訳の好みを設定したり、カスタム用語集をアップロードしたり、ライブエディタ翻訳インターフェイスにアクセスして翻訳結果を手動で編集したりできます。これにより、ユーザーはニーズに応じて翻訳の精度を向上させることができます。
  • Google翻訳: カスタマイズと制御のオプションがより限られています。ユーザーは自動翻訳結果に頼る必要があり、結果を編集または直接カスタマイズする能力はあまりありません。

高度な機能

アクセシビリティ機能付きのコンピュータ画面とコーヒーカップ
  • Google Cloud AI API 翻訳: Google Cloud AI 翻訳テクノロジーには、用語集、モデル選択、AutoML モデルなどの高度な機能がいくつかあります。さらに、Linguise でのクラウド AI 翻訳のコンテキストでは、行、ページ、または URL に基づいて、専門用語、ブランド名などの特定の単語の 翻訳除外 などの高度な機能もあります。
  • Google翻訳: LaravelにインストールされたGoogle翻訳は、音声ドキュメントやその他の翻訳はできません。ウェブサイト上のテキストを別の言語に翻訳することしかできず、翻訳結果を編集する機能もありません。
言語の壁を壊す
言語の障壁に別れを告げ、無限の成長にこんにちは!私たちの自動翻訳サービスを今すぐお試しください。.

Laravel ウェブサイトの翻訳サービスを選択する際に考慮すべき要素

ここでは、 Laravel ウェブサイトに最適な翻訳サービスを選択する際の考慮事項をいくつか紹介します。.

  • 高い翻訳精度 – 最も重要な要素の1つは、生成された翻訳の精度です。ウェブサイトで高精度の翻訳が必要な場合、特に複雑なコンテンツや微妙な言語の場合、Google Cloud AI API翻訳はGoogle翻訳よりも適している可能性があります。
  • 統合と設定の容易さ —翻訳サービスをLaravelアプリケーションにインストールして設定することを検討してください。一般的に、Google翻訳はPHPパッケージまたはライブラリとして利用できるため、統合が容易です。一方、Google Cloud AI API翻訳では、Google Cloud Platformでのより複雑な設定が必要です。
  • 機能とカスタマイズオプション – 用語集や専門用語の翻訳、エディタ翻訳結果などの追加機能やその他のカスタマイズオプションが必要な場合、Google Cloud AI API TranslationはGoogle翻訳よりも多くの選択肢を提供します。
  • 速度とレスポンス時間 – 多くの翻訳ボリュームを持つアプリケーションや迅速なレスポンスが必要な場合、Google Cloud AI API Translationは一般的にGoogle翻訳よりも迅速に翻訳リクエストに対応します。
  • コストと予算 – Google翻訳は、非商用利用の場合無料で利用できますが、Google Cloud AI API翻訳は、使用量に基づく有料の課金モデルを使用しています。予算と推定翻訳量を考慮して、最もコスト効率の高いサービスを選択してください。
  • サポートとドキュメント – また、各サービスで利用できるテクニカルサポートとドキュメントを考慮してください。Google Cloud AI API翻訳は、Googleからのより包括的なドキュメントとサポートを提供している可能性があります。

Laravel ウェブサイトに最適なクラウドAI翻訳サービス、Linguise

プロフェッショナルなウェブサイトの設計と開発サービス、SEO最適化

この時点までに、 Laravelの翻訳サービスを選択する際の考慮事項がすでにわかっています。上記の要因のほとんどは、 Linguise 翻訳サービスに存在します。.

Linguiseは、クラウドAI翻訳技術を使用してコンテンツ翻訳を生成するウェブサイト翻訳サービスです。このサービスは、Laravelベースのウェブサイトを翻訳するための最良の解決策となり得ます。なぜそうなのか?それは、Linguiseが上記の考慮事項に対応しているからです。

  • Linguiseは完璧な翻訳品質を誇ります。言語の組み合わせによって精度は異なりますが、Linguiseは人間による翻訳と同様の約97%の精度を実現しています。
  • Linguise は、40 以上の CMS および Web ビルダーと統合されており、 PHP ベースの Web サイト (Laravel など) とも統合されています。
  • 自動翻訳ですが、 Linguise には翻訳結果を編集できるライブエディターがあります。このようにして、翻訳はビジネスの好みに合わせて調整できます。.
  • 多言語ページの読み込み時間は、元の言語ページと比べてわずか5%長くなります。.
  • 私たちのサービスは、月額15ドルから45ドルの3つのパッケージで提供されています。有料ではありますが、30日間の無料トライアル期間も設けており、60万語までの翻訳が可能です。.
  • 最終的に、 Linguise は、ガイド記事、ドキュメント、製品ニュース、YouTubeビデオチュートリアル、24時間365日のサポートチャットなど、すべての形式の顧客サポートを提供します。.

上記の点から、 Linguise は LaravelのためのクラウドAI翻訳技術ソリューションになる可能性があります。.

新しい市場を開拓する準備はできていますか? 1ヶ月のリスクフリー試用で無料で自動翻訳サービスをお試しください。クレジットカードは不要です!

結論

この記事では、Google Cloud AI API翻訳とGoogle翻訳を Laravel ウェブアプリケーションに実装する際の主な違いについて説明します。.

Google Cloud AI API 翻訳は、正確さと高精度の翻訳の必要性に優れています。ただし、このサービスは、Google 翻訳よりも複雑な構成と高価です。一方、Google 翻訳は、統合の容易さを提供しますが、精度とカスタマイズ オプションに制限があります。.

Linguise は、 Laravel ウェブサイトと互換性のある代替クラウドAIベースの翻訳サービスとして登場します。人間の翻訳に匹敵する精度、翻訳エディターオプション、高速な読み込み時間、包括的な顧客サポートにより、 Linguise は Laravel ウェブサイトに優れた翻訳ソリューションを提供します。.

もしあなたがLinguiseを試してみたいなら、無料アカウントに登録して、60万語の翻訳制限付きで30日間のトライアル期間を利用できます。詳細については、linguise.comをご覧ください!

また、以下の記事にも興味をお持ちかもしれません

お見逃しなく!
ニュースレターを購読する

ウェブサイトの自動翻訳、国際SEOなどの最新情報をご覧いただけます!

Invalid email address
試してみてください。月額1回、いつでも退会できます。.

メールアドレスを共有してからお立ち回りください!

宝くじに当選することを保証することはできませんが、翻訳に関する興味深い情報や時折割引情報をお約束します。.

お見逃しなく!
Invalid email address