What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi Everyone! I am trying to package a module properly so it can be easily reused. The problem I’m fa

U03EDGXUTPH
U03EDGXUTPH Posts: 36 🧑🏻‍🚀 - Cadet
edited April 2023 in Help

Hi Everyone! I am trying to package a module properly so it can be easily reused. The problem I’m facing now is with packaging default translations for the strings.
I can’t see an obvious place to store them.
If I create a mymodule.stringname glossary reference, how should I attach the translations to it?
Should I just create a csv and point out in the instructions that translations should be added to the importer?

Comments

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet

    If you build packages and use ur own namespace, the people who uses ur package has to configure the stack for this purpose. The normal way adding translations is to add them into "data/translation/Zed". So spryker itself scan ootb with

    APPLICATION_VENDOR_DIR . '/spryker/*/data/translation/Zed/[a-z][a-z]_[A-Z][A-Z].csv'
    

    For your doing you have to extend the TranslatorConfig on pyz with your own path/pattern and provide the information via instructions.

    So for the fond-of* vendor packages the required configuration is

    <?php
    
    
    namespace Pyz\Zed\Translator;
    
    use Spryker\Zed\Translator\TranslatorConfig as SprykerTranslatorConfig;
    
    class TranslatorConfig extends SprykerTranslatorConfig
    {
        /**
         * @return array<string>
         */
        public function getTranslationFilePathPatterns(): array
        {
            $pathPatterns = parent::getTranslationFilePathPatterns();
    
            $pathPatterns[] = APPLICATION_VENDOR_DIR . '/fond-of-spryker/*/data/translation/Zed/[a-z][a-z]_[A-Z][A-Z].csv';
            $pathPatterns[] = APPLICATION_VENDOR_DIR . '/fond-of-oryx/*/data/translation/Zed/[a-z][a-z]_[A-Z][A-Z].csv';
            $pathPatterns[] = APPLICATION_VENDOR_DIR . '/fond-of-oryx/fond-of-oryx/bundles/*/data/translation/Zed/[a-z][a-z]_[A-Z][A-Z].csv';
    
            return $pathPatterns;
        }
    }
    
  • U03EDGXUTPH
    U03EDGXUTPH Posts: 36 🧑🏻‍🚀 - Cadet

    thanks @UK7KBE2JW, very helpful. Exactly what I was looking for 🙂

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet

    ur welcome