gymmed/laravel-package-translator

Translates laravel package language document using google translate. Works for ecommerce bagisto documents.

v0.0.1 2024-10-14 23:45 UTC

This package is auto-updated.

Last update: 2025-02-17 07:59:01 UTC


README

Laravel Package Translator


Laravel Package Translator Logo.

Neat way to translate Laravel package documents with google translate. Highly recommend for Bagisto package development. This package uses stichoza/google-translate-php to translate.

Installation

You can install the package via composer:

composer require gymmed/laravel-package-translator

Usage

To use the command with arguments and options, follow this format:

package-translator:translate {package} {translateFrom} {translateTo} {--comments} {--force}

Explanation of Arguments:

  • {package}: The package path, e.g., Namespace/PackageName
  • {translateFrom}: Language code with source translation file, e.g., en/app
  • {translateTo}: Language code with target translation file, e.g., lt/app
  • {--comments}: (Optional) If you want to include comments.
  • {--force}: (Optional) If you want to force the operation.

usage example:

php artisan package-translator:translate Webkul/Shop en/app lt/app

will translate document from:

rootDirectory/packages/Webkul/Shop/src/Resources/lang/en/app.php

will create translated document in:

rootDirectory/packages/Webkul/Shop/src/Resources/lang/lt/app.php

returned results:

Translation results.

You can translate and leave original text as comments for manual double checking:

php artisan package-translator:translate Webkul/Shop en/app lt/app --comments --force

Use --force option to overwrite document.

returned results:

Translation results with comments.

as code from:

return [
  ...
  'datagrid' => [
      'toolbar' => [
          'length-of' => ':length of',
          'results'   => ':total Results',
          'selected'  => ':total Selected',

          'mass-actions' => [
              'must-select-a-mass-action'        => 'You must select a mass action.',
              'must-select-a-mass-action-option' => 'You must select a mass action\'s option.',
              'no-records-selected'              => 'No records have been selected.',
              'select-action'                    => 'Select Action',
          ],
        ...
];

to:

return [
  ...
  'datagrid' => [
    'toolbar' => [
        'length-of' => ' :length iš', /* :length of */
        'results'   => ' :total Rezultatai', /* :total Results */
        'selected'  => ' :total Pasirinkta', /* :total Selected */

        'mass-actions' => [
            'must-select-a-mass-action'        => 'Turite pasirinkti masinį veiksmą.', /* You must select a mass action. */
            'must-select-a-mass-action-option' => 'Turite pasirinkti masinio veiksmo parinktį.', /* You must select a mass action\'s option. */
            'no-records-selected'              => 'Nepasirinkta jokių įrašų.', /* No records have been selected. */
            'select-action'                    => 'Pasirinkite Veiksmas', /* Select Action */
        ],
        ...
];

If you decide you don't want comments anymore, you can use:

package-translator:uncomment {package} {languageCodeAndFile}

example:

php artisan package-translator:uncomment Webkul/Shop lt/app

returned results:

Translation results with removed comments.