Controller/GeoIP/GetAction.php
private function getMessageInStoreLocale(StoreInterface $emulatedStore)
    {
        $currentStore = $this->storeManager->getStore();

        // emulate locale and store of new store to fetch message translation
        $this->localeResolver->emulate($emulatedStore->getId());
        $this->storeManager->setCurrentStore($emulatedStore->getId());

        $message = __(
            'You are in the wrong store. Click OK to visit the %1 store.',
            [$emulatedStore->getName()]
        )->__toString();

        // revert locale and store emulation
        $this->localeResolver->revert();
        $this->storeManager->setCurrentStore($currentStore->getId());

        return $message;
    }
private function getMessageInStoreLocale(StoreInterface $emulatedStore)
    {
        $currentStore = $this->storeManager->getStore();

        // emulate locale and store of new store to fetch message translation
        $this->localeResolver->emulate($emulatedStore->getId());
        $this->storeManager->setCurrentStore($emulatedStore->getId());

        $message = __(
            'You are in the wrong store. Click OK to visit the %1 store.',
            [$emulatedStore->getName()]
        )->__toString();

        // revert locale and store emulation
        $this->localeResolver->revert();
        $this->storeManager->setCurrentStore($currentStore->getId());

        return $message;
    }
Gets the dialog message in the locale of the target store.
@param StoreInterface $emulatedStore
@return string
@throws \Magento\Framework\Exception\NoSuchEntityException