Search code examples
shopware

How i use the English translation as fallback in plugin ( Shopware 6 )


Hi i try to publish a plugin in the Shopware store.after review my plugin, from Shopware send to me an error.

The plugin cannot be installed. The plugin could not be installed due to the error message "Translation required for system language 2fbb5fe2e29a4d70aa5854ce7ce3e20b" The default language must be selected during installation.

I search about it and i found this document

Fallback language The installation is not always in English or German. So make sure that your extension works in other languages as well. An example: The customer has his installation in Spanish, your extension is not yet available in this language. So you should use the English translation as fallback.

I don't know how i can define default language in my plugin

UPDATE

Before than, I defined snippet file in service.yml without priority option

<service id="MyNamespace\Resources\snippet\en_GB\SnippetFile_en_GB" public="true">
   <tag name="shopware.snippet.file" />
</service>
<service id="MyNamespace\Resources\snippet\de_DE\SnippetFile_de_DE" public="true">
   <tag name="shopware.snippet.file"/>
</service>

Now it's

<service id="MyNamespace\Resources\snippet\en_GB\SnippetFile_en_GB" public="true">
   <tag name="shopware.snippet.file" priority="100"/>
</service>
<service id="MyNamespace\Resources\snippet\de_DE\SnippetFile_de_DE" public="true">
   <tag name="shopware.snippet.file" priority="100"/>
</service>

PS:I don't us of config.xml file.Is it possible that error relate to it.For example, User can select default the language in config plugin??


Solution

  • a better solution should be:

    use Shopware\Core\Defaults;
    
    ...
    
    'label' => [
         'en-GB' => 'my english label',
         'de-DE' => 'meine deutsche Beschriftung',
         Defaults::LANGUAGE_SYSTEM => 'my default language label',
    ]
    
    ...
    

    Best regards

    Sebastian