Magento 2 Country Name not get translated when using countryFactoryHow to get country name from country code?Magento 2 configure stock by websitemain.CRITICAL: Plugin class doesn't existHow to get Country ID from Country Name in Magento1.9.2.4?Why Getting categories and names on product view page Magento 2 fails?Magento 2.2.5: explain about how the multi select “available_sort_by” get dataMagento 2: Required parameter 'theme_dir' was not passedChange country name in magento 2.2Magento 2.3 email attachment not working while sending custom email

How to protect bash function from being overridden?

Drawing Maps; flat distortion

Is "Ram married his daughter" ambiguous?

Would a horse be sufficient buffer to prevent injury when falling from a great height?

Looking for circuit board material that can be dissolved

Did the Soviet army intentionally send troops (e.g. penal battalions) running over minefields?

Found a minor bug, affecting 1% of users. What should QA do?

Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?

Is the "spacetime" the same thing as the mathematical 4th dimension?

Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails

Can Fabled Passage generate two mana with Amulet of Vigor?

Job interview by video at home and privacy concerns

Duck, duck, gone!

Short story about a potato hotel that makes its guests into potatoes throughout the night

What does a textbook look like while you are writing it?

Manager told a colleague of mine I was getting fired soon

Quote to show students don't have to fear making mistakes

Why has Speaker Pelosi been so hesitant to impeach President Trump?

Can a passenger predict that an airline or a tour operator is about to go bankrupt?

Magento 2 Country Name not get translated when using countryFactory

Why do popular TCP-using services have UDP as well as TCP entries in /etc/services?

Giving a good fancy look to a simple table

Why not add cuspidal curves in the moduli space of stable curves?

Is there a pattern for handling conflicting function parameters?



Magento 2 Country Name not get translated when using countryFactory


How to get country name from country code?Magento 2 configure stock by websitemain.CRITICAL: Plugin class doesn't existHow to get Country ID from Country Name in Magento1.9.2.4?Why Getting categories and names on product view page Magento 2 fails?Magento 2.2.5: explain about how the multi select “available_sort_by” get dataMagento 2: Required parameter 'theme_dir' was not passedChange country name in magento 2.2Magento 2.3 email attachment not working while sending custom email






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1















My Magento site have about 10 different websites and one for each country. I have set the correct Locale corresponding to each country (storeview).



I'm getting Country Name by using countryFactory, the problem is, when switching Storeview, it doesn't get me the country name translated according to the Locale i configured in the admin.



public function __construct(
MagentoDirectoryModelCountryFactory $countryFactory
)

$this->countryFactory = $countryFactory;


public function getCountryName($code)

$_country = $this->countryFactory->create()->loadByCode($code);
if($_country)

return $_country->getName();


return false;



How do I get country name translated when switching the storeview?










share|improve this question






























    1















    My Magento site have about 10 different websites and one for each country. I have set the correct Locale corresponding to each country (storeview).



    I'm getting Country Name by using countryFactory, the problem is, when switching Storeview, it doesn't get me the country name translated according to the Locale i configured in the admin.



    public function __construct(
    MagentoDirectoryModelCountryFactory $countryFactory
    )

    $this->countryFactory = $countryFactory;


    public function getCountryName($code)

    $_country = $this->countryFactory->create()->loadByCode($code);
    if($_country)

    return $_country->getName();


    return false;



    How do I get country name translated when switching the storeview?










    share|improve this question


























      1












      1








      1








      My Magento site have about 10 different websites and one for each country. I have set the correct Locale corresponding to each country (storeview).



      I'm getting Country Name by using countryFactory, the problem is, when switching Storeview, it doesn't get me the country name translated according to the Locale i configured in the admin.



      public function __construct(
      MagentoDirectoryModelCountryFactory $countryFactory
      )

      $this->countryFactory = $countryFactory;


      public function getCountryName($code)

      $_country = $this->countryFactory->create()->loadByCode($code);
      if($_country)

      return $_country->getName();


      return false;



      How do I get country name translated when switching the storeview?










      share|improve this question














      My Magento site have about 10 different websites and one for each country. I have set the correct Locale corresponding to each country (storeview).



      I'm getting Country Name by using countryFactory, the problem is, when switching Storeview, it doesn't get me the country name translated according to the Locale i configured in the admin.



      public function __construct(
      MagentoDirectoryModelCountryFactory $countryFactory
      )

      $this->countryFactory = $countryFactory;


      public function getCountryName($code)

      $_country = $this->countryFactory->create()->loadByCode($code);
      if($_country)

      return $_country->getName();


      return false;



      How do I get country name translated when switching the storeview?







      magento2 locale countries






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      Magento LearnerMagento Learner

      82514 silver badges41 bronze badges




      82514 silver badges41 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          4
















          Use locale code as param in getName



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory
          )
          $this->countryFactory = $countryFactory;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          return $_country->getName('Your locale code');


          return false;



          Example:



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory,
          MagentoStoreModelStoreManagerInterface $storeManager,
          MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
          )

          $this->countryFactory = $countryFactory;
          $this->_storeManager = $storeManager;
          $this->scopeConfig = $scopeConfig;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          /* current store id */
          $storeId = $this->_storeManager->getStore()->getId();
          return $_country->getName($this->getStoreLocale($storeId));


          return false;


          private function getStoreLocale($storeId)

          $locale = $this->scopeConfig->getValue('general/locale/code', MagentoStoreModelScopeInterface:: SCOPE_STORE, $storeId);
          return $locale;






          share|improve this answer

























          • Great, it's working. thanks

            – Magento Learner
            7 hours ago











          • Welcome @MagentoLearner

            – Ranganathan
            7 hours ago












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f290942%2fmagento-2-country-name-not-get-translated-when-using-countryfactory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4
















          Use locale code as param in getName



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory
          )
          $this->countryFactory = $countryFactory;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          return $_country->getName('Your locale code');


          return false;



          Example:



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory,
          MagentoStoreModelStoreManagerInterface $storeManager,
          MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
          )

          $this->countryFactory = $countryFactory;
          $this->_storeManager = $storeManager;
          $this->scopeConfig = $scopeConfig;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          /* current store id */
          $storeId = $this->_storeManager->getStore()->getId();
          return $_country->getName($this->getStoreLocale($storeId));


          return false;


          private function getStoreLocale($storeId)

          $locale = $this->scopeConfig->getValue('general/locale/code', MagentoStoreModelScopeInterface:: SCOPE_STORE, $storeId);
          return $locale;






          share|improve this answer

























          • Great, it's working. thanks

            – Magento Learner
            7 hours ago











          • Welcome @MagentoLearner

            – Ranganathan
            7 hours ago















          4
















          Use locale code as param in getName



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory
          )
          $this->countryFactory = $countryFactory;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          return $_country->getName('Your locale code');


          return false;



          Example:



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory,
          MagentoStoreModelStoreManagerInterface $storeManager,
          MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
          )

          $this->countryFactory = $countryFactory;
          $this->_storeManager = $storeManager;
          $this->scopeConfig = $scopeConfig;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          /* current store id */
          $storeId = $this->_storeManager->getStore()->getId();
          return $_country->getName($this->getStoreLocale($storeId));


          return false;


          private function getStoreLocale($storeId)

          $locale = $this->scopeConfig->getValue('general/locale/code', MagentoStoreModelScopeInterface:: SCOPE_STORE, $storeId);
          return $locale;






          share|improve this answer

























          • Great, it's working. thanks

            – Magento Learner
            7 hours ago











          • Welcome @MagentoLearner

            – Ranganathan
            7 hours ago













          4














          4










          4









          Use locale code as param in getName



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory
          )
          $this->countryFactory = $countryFactory;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          return $_country->getName('Your locale code');


          return false;



          Example:



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory,
          MagentoStoreModelStoreManagerInterface $storeManager,
          MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
          )

          $this->countryFactory = $countryFactory;
          $this->_storeManager = $storeManager;
          $this->scopeConfig = $scopeConfig;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          /* current store id */
          $storeId = $this->_storeManager->getStore()->getId();
          return $_country->getName($this->getStoreLocale($storeId));


          return false;


          private function getStoreLocale($storeId)

          $locale = $this->scopeConfig->getValue('general/locale/code', MagentoStoreModelScopeInterface:: SCOPE_STORE, $storeId);
          return $locale;






          share|improve this answer













          Use locale code as param in getName



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory
          )
          $this->countryFactory = $countryFactory;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          return $_country->getName('Your locale code');


          return false;



          Example:



          <?php
          public function __construct(
          MagentoDirectoryModelCountryFactory $countryFactory,
          MagentoStoreModelStoreManagerInterface $storeManager,
          MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
          )

          $this->countryFactory = $countryFactory;
          $this->_storeManager = $storeManager;
          $this->scopeConfig = $scopeConfig;


          public function getCountryName($code)

          $_country = $this->countryFactory->create()->loadByCode($code);
          if($_country)
          /* current store id */
          $storeId = $this->_storeManager->getStore()->getId();
          return $_country->getName($this->getStoreLocale($storeId));


          return false;


          private function getStoreLocale($storeId)

          $locale = $this->scopeConfig->getValue('general/locale/code', MagentoStoreModelScopeInterface:: SCOPE_STORE, $storeId);
          return $locale;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          RanganathanRanganathan

          1,5636 silver badges22 bronze badges




          1,5636 silver badges22 bronze badges















          • Great, it's working. thanks

            – Magento Learner
            7 hours ago











          • Welcome @MagentoLearner

            – Ranganathan
            7 hours ago

















          • Great, it's working. thanks

            – Magento Learner
            7 hours ago











          • Welcome @MagentoLearner

            – Ranganathan
            7 hours ago
















          Great, it's working. thanks

          – Magento Learner
          7 hours ago





          Great, it's working. thanks

          – Magento Learner
          7 hours ago













          Welcome @MagentoLearner

          – Ranganathan
          7 hours ago





          Welcome @MagentoLearner

          – Ranganathan
          7 hours ago


















          draft saved

          draft discarded















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f290942%2fmagento-2-country-name-not-get-translated-when-using-countryfactory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

          The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

          19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу