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;
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 8 hours ago
Magento LearnerMagento Learner
82514 silver badges41 bronze badges
82514 silver badges41 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
7 hours ago
Welcome @MagentoLearner
– Ranganathan
7 hours ago
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
7 hours ago
Welcome @MagentoLearner
– Ranganathan
7 hours ago
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
7 hours ago
Welcome @MagentoLearner
– Ranganathan
7 hours ago
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 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
add a comment
|
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
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