Magento 2 Country Name not get translated when using countryFactoryHow to get country name from country code?Magento 2 configure stock by websiteMagento 2 main.CRITICAL: Plugin class doesn't existHow to get Country ID from Country Name in Magento1.9.2.4?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
Where is the Windows license key on Windows 10?
How much do I need to invest monthly to accumulate a given amount?
Resources to study quantum algorithms and quantum complexity
Is Yoda made using CGI in the original Star Wars or is it practical effects?
"Don't invest now because the market is high"
Why did my LGA-ORD flight make an S-shaped turn round the time it was passing a storm?
How to move directory into a directory with the same name?
What is the origin of 没 as an alternative to 不?
What is the name of this part of drawers?
How many times, are they multiples?
Keeping data in old Database (SQL 2008) identical to new Database (SQL 2016)?
Perambulating ants
How to set up a "Forced choice" for players in a game?
How could Olaf survive without his flurry in Frozen II?
Can be a natural language be non-serializable?
How to delete data extensions if I can't access them?
How to compute the cohomology of a local system?
Computer power supplies usually have higher efficiency on 230V than on 115V. Why?
What are examples of (collections of) papers which "close" a field?
Can one get into trouble if one doesn't show up at the gate 30 minutes before departure (or whatever time window the boarding pass is indicating)?
Are soldered electrical connections code-compliant?
What would happen if the Queen died immediately before a general election?
Schemes/ Mechanisms that could provide one time decryption?
Could a technologically advanced society exist as a feudal monarchy?
Magento 2 Country Name not get translated when using countryFactory
How to get country name from country code?Magento 2 configure stock by websiteMagento 2 main.CRITICAL: Plugin class doesn't existHow to get Country ID from Country Name in Magento1.9.2.4?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;
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
add a comment
|
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
add a comment
|
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
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
magento2 locale countries
asked Sep 26 at 9:29
Magento LearnerMagento Learner
1,49016 silver badges42 bronze badges
1,49016 silver badges42 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
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;
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
add a comment
|
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;
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
add a comment
|
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;
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;
answered Sep 26 at 9:35
RanganathanRanganathan
2,4991 gold badge6 silver badges27 bronze badges
2,4991 gold badge6 silver badges27 bronze badges
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
add a comment
|
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Great, it's working. thanks
– Magento Learner
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
Welcome @MagentoLearner
– Ranganathan
Sep 26 at 9:47
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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