Git Product home page Git Product logo

translation-factory's Introduction

Laravel Translation Factory

Laravel Version GitHub license

Translation Factory is a tool for the Laravel framework that helps to create and manage translations. Especially it helps to coordinate multiple translators and translators which do not want to edit PHP files, aiding them with AI translations.

Screenshot

Note: "Factory" does not mean the pattern here but rather this: 🏭

Highlights

  • Seamless integration into your existing Laravel application
  • Uses DeepL - currently the best machine translation engine - to auto-translate texts
  • Beautiful user interface and made with a good user experience in mind
  • Well prepared for mobile devices (smartphones and tablets)
  • Highly configurable and easy to extend
  • Open source and free even for commercial use

Installation

This library requires PHP 7.0 or higher with the cURL extension and Laravel >= 5.5.

Through Composer:

composer require chriskonnertz/translation-factory

Publish the assets via: php artisan vendor:publish --provider="ChrisKonnertz\TranslationFactory\Integration\TranslationFactoryServiceProvider

Make sure Translation Factory can write into the output directories, especially you should make the translation directory writable, for example resources/lang.

If you do not want to enable support of user accounts, that's it. Navigate to http://<your-domain>/translation-factory to start.

Configuration

Open config/translation_factory.php with a text editor to change the configuration. All entries are documented. Especially take a look at the additional_languages key. In this array you may add language codes of the languages that you want to support. Translation Factory tires to auto-detect these languages but this will only be successful if there are at least one translation file for each of these languages, so better add them to the array.

User Accounts With Laravel

This package supports user authentication. Per default it depends on Laravel's built-in user authentication system. If you want to enable support of user accounts you have to do this in the config file (key: user_authentication). You also have to add the user IDs of all administrators to the config file (key: user_admin_ids).

If you already use Laravel's user authentication then you can skip the rest of this section. But if you have a fresh installation of Laravel follow these steps to prepare it:

  1. Via console run php artisan make:auth to create resources like controllers and views
  2. Then run php artisan migrate to prepare the database

Now the translators will be able to navigate to http://<your-domain>/home and log in or create a new user account.

If you do not want to use Laravel's built-in user authentication system you have to create your own user manager that implements the UserManagerInterface. Introduce it to Translation Factory by adding its name to the config file (key: user_manager).

Use With External Translators

If you want to use Translation Factory to let external translators translate your texts, it is recommended to follow these steps:

  1. Setup a new server with your application. The server has to be reachable from the outside
  2. Make sure Translation Factory can write into the output directories
  3. Configure everything, especially enable user authentication
  4. Create your own account and then add it to the admins list in the config file
  5. Let the externals create their user accounts (http://<your-domain>/register)
  6. Activate the accounts of the translators
  7. Spread the link: http://<your-domain>/translation-factory
  8. Happy translating!

Backups

The default behaviour of Translation Factory is to make daily backups of all translation files that it wants to overwrite. They will be stored in <storage-path>/app/translations which usually translates to storage/app/translations. You may change this path in the config file (key: backup_dir). The names of the backup files will be built of a hash and the date and use ".backup" as extension.

Current State

This is an MVP (minimum viable product). The code quality is okay, but for sure it is not great. There is a lot of space for refactoring. Refactoring will be done if it turns out that this package actually meets someones needs.

FAQ

  • Which languages can be auto-translated? Here is a list: Link
  • Why are characters missing in the auto-translation? This is an issue of DeepL. Always verify the auto-translations!
  • Does this also work with Laravel < 5.5? Maybe. Not tested, though. You would have to register the TranslationFactoryServiceProvider.
  • Should I use barryvdh/laravel-translation-manager? LTM offers some features that help to handle translations, for example finding translations that are missing in the translations files. That makes it a good addition to Translation Factory. Translation Factory on the other hand is focused on translating. It has a sophisticated user interface and uses DeepL to help the translator, which makes it a good choice for translating.
  • I got this exception: "SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes" Here is a solution: Link
  • What library is used for the auto-translations? DeepLy
  • How can I auto-translate all of my translation files? Laravel Localization Automation might be worth a look.

translation-factory's People

Contributors

chriskonnertz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

translation-factory's Issues

Fix Link Color

The link color in the footer on the config file is not red but purple (=original Spectre color).

(Linux, Chromium)

Ideas

Ideas:

  • Make the dashboard more informative
  • Fire important events
  • Update "already translated" state in the items list when the current item has been translated
  • Show infos about what has been translated already (stats on dashboard and "is translated" marker in item selector)
  • Cache an array with hashes as keys and file names as items (not sure if this is really necessary)
  • Translate the app
  • Do not use var_export() to export the arrays but write a custom method with better formatting
  • AJAXify choosing an item (=use AJAX to load the item instead of reloading the whole page)
  • Make the application work is JS is disabled (not very likely to happen) UPDATE: Not happening
  • Create a layer between the original translation files and the file output. Might be useful if we want to add meta information,for example the user ID of the creater of a translation.
  • Escape line breaks when writing them to translation files (just calling addcslashes() is not enough!)
  • "Auto-Translate" button (to force DeepL to translate again)

Todo:

  • Important: Protect links ("a" element) against CSRF attacks by adding the CSRF token
  • Login issue
  • Mobile optimization

ToDo: Enhance README.md

It might make sense to emphasize how actually use this tool, especially where the translations are stored.

php artisan vendor:publish requested even if run

I did run

$ php artisan vendor:publish --provider="ChrisKonnertz\TranslationFactory\Integration\TranslationFactoryServiceProvider"
Publishing complete.

But the web interface still shows:

Exception
Please publish the assets of the Translation Factory package via: "php artisan vendor:publish --provider="ChrisKonnertz\TranslationFactory\Integration\TranslationFactoryServiceProvider"

Laravel Framework 5.5.32

Call to undefined function ChrisKonnertz\TranslationFactory\title_case()

Hello,

I'm trying your package.
I'm using Laravel 9, had no installation problem.
A soon as I'm trying to open a translation file I'm having this error...
Look like it's coming form a call in the blade file (chriskonnertz / translation-factory / src/ ChrisKonnertz /TranslationFactory /resources/ views / file.blade.php):

<h1 title="{{ $translationBag->getBaseFile() }}">{{ $translationBag->getTitle() }}</h1>

Any idea why ?
Thanks, Denis

Line breaks

It seems like line breaks in the translation text area are incorrectly written to the translation file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.