phpro / phpro-mage2-module-translations Goto Github PK
View Code? Open in Web Editor NEWTranslation module for Magento 2
License: MIT License
Translation module for Magento 2
License: MIT License
Make feature to retrieve all untranslated strings, something like following: https://github.com/ericthehacker/magento-untranslatedstrings
Used following plugin to fix
<?php
declare(strict_types=1);
namespace Vendor\PhproTranslations\Plugin;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\StoreManager;
use Phpro\Translations\Model\Translation\Source\Locales as SourceLocales;
class Locales
{
private const XML_PATH_LOCALE = 'general/locale/code';
public function __construct(
private readonly ScopeConfigInterface $scopeConfig,
private readonly StoreManager $storeManager,
) {
}
/**
* @param SourceLocales $subject
* @param callable $proceed
* @return array
*/
public function aroundToOptionArray(SourceLocales $subject, callable $proceed): array
{
$stores = $this->storeManager->getStores();
$result = [];
foreach ($stores as $store) {
$locale = $this->scopeConfig->getValue(self::XML_PATH_LOCALE, 'stores', $store->getId());
$result[] = ['value' => $locale, 'label' => $store->getName()];
}
return $result;
}
}
Package phpro/mage2-module-translations has requirements incompatible with your PHP version, PHP extensions and Composer version:
- phpro/mage2-module-translations 0.1.1 requires php ^7.1 which does not match your installed version 8.1.2.
Hi, while using the module's commans i encountered the following error:
There is an error in /app/vendor/symfony/console/Command/Command.php at line: 301
Return value of "Phpro\Translations\Console\Command\ImportFull\Interceptor::execute()" must be of the type int, "null" returned.
#0 /app/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\C
ommand->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /app/vendor/magento/framework/Interception/Interceptor.php(138): Phpro\Translations\Console\Command\ImportFull\Interceptor->___callParent('run', Array)
#2 /app/vendor/magento/framework/Interception/Interceptor.php(153): Phpro\Translations\Console\Command\ImportFull\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symf
ony\Component\Console\Output\ConsoleOutput))
#3 /app/generated/code/Phpro/Translations/Console/Command/ImportFull/Interceptor.php(77): Phpro\Translations\Console\Command\ImportFull\Interceptor->___callPlugins('run', Array, Array)
#4 /app/vendor/symfony/console/Application.php(1040): Phpro\Translations\Console\Command\ImportFull\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Phpro\Translations\Console\Command\ImportFull\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(
Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/bin/magento(23): Symfony\Component\Console\Application->run()
#9 {main}
This happens with all of the follwoing commands:
The current way how translation are stored is decided in \Phpro\Translations\Model\InlineTranslationsGenerator::generate
This function will loop over all stores and get the active theme. This will not take into account any other theme that could be inactively used.
Example:
Hyva used a fallback theme in the checkout. This theme can be custom as well.
The frontend store will use theme: translation_frontent.
The checkout of hyva will use the backend theme: translation_checkout.
The translation_checkout theme is not actively set on a store view.
The translation file (location in pub/media/phpro_translations/{theme}/{name}}) will not be created as it is not set to a store that is looped over in \Phpro\Translations\Model\InlineTranslationsGenerator::generate.
Proposed solution
Loop over all static frontend themes (pub/static/frontend) and all decendent locales to generate the correct translations file. This way if you would configure a different theme on a store view it would still work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.