I wish to translate store language switcher label dropdown from english to simplified chinese. PFA for thes same.
2 Answers
copy file app/design/frontend/base/default/template/page/switch/languages.phtml
into your theme
add below code
echo $this->__(<Text to translate>);
you want to translate
$this->escapeHtml($_lang->getName())
so
$this->__($this->escapeHtml($_lang->getName()))
Your final code
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->__($this->escapeHtml($_lang->getName())) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
Add entry in csv file for translation
i have this in 2.4 how to translate the string:
getStores()) > 1): ?><?php $id = $block->getIdModifier() ? '-' . $block->getIdModifier() : '' ?>
<div class="switcher language switcher-language" data-ui-id="language-switcher"
id="switcher-language<?php /* @escapeNotVerified */
echo $id ?>">
<strong class="label switcher-label"><span><?php /* @escapeNotVerified */
echo __('Language') ?></span></strong>
<div class="switcher-content">
<div class="action-switcher" id="switcher-language-trigger<?php /* @escapeNotVerified */
echo $id ?>">
<div class="heading-switcher view-<?php echo $block->escapeHtml($block->getCurrentStoreCode()) ?>"
style="background-repeat: no-repeat; background-image:url('<?php /* @escapeNotVerified */
echo $block->getViewFileUrl('images/flags/flag_' . $block->getCurrentStoreCode() . '.svg') ?>');">
<span><?php echo $block->escapeHtml($block->getStoreName()) ?></span>
</div>
</div>
<div class="dropdown-switcher">
<ul class="list-item">
<?php foreach ($block->getStores() as $_lang): ?>
<?php if ($_lang->getId() != $block->getCurrentStoreId()): ?>
<li class="view-<?php echo $block->escapeHtml($_lang->getCode()); ?> switcher-option">
<a href="#" data-post='<?php /* @escapeNotVerified */
echo $block->getTargetStorePostData($_lang); ?>'>
<span style="background-repeat: no-repeat; background-image:url('<?php /* @escapeNotVerified */
echo $block->getViewFileUrl('images/flags/flag_' . $_lang->getCode() . '.svg') ?>');"><?php echo $block->escapeHtml($_lang->getName()) ?></span>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>