Giter VIP home page Giter VIP logo

phpro-mage2-module-translations's People

Contributors

brentrobert avatar dylanteugels avatar maximganses avatar siebdc2 avatar stefliekens avatar vacla avatar vrielsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phpro-mage2-module-translations's Issues

Locales are not found if set in env.php and not in core_config_table

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;
    }
}

Php 8.1 Compability

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.

execute method of commands should always return an int

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:

  • Console/Command/Export.php
  • Console/Command/GenerateFrontendTranslations.php
  • Console/Command/Import.php
  • Console/Command/ImportFull.php
  • Console/Command/PrepareKeysCommand.php

Feature: use themes generated in pub/static/frontend to generate translation.json files

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.

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.