Skip to content

Commit

Permalink
Fix multilanguage plugin (previous hack)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-gardener committed Jul 23, 2024
1 parent 1e2101c commit d141b4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions plugins/Multilanguage/helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,33 @@ function locale_human($locale)
if (isset($parts[1])) {
$langCode = $parts[0];
$regionCode = $parts[1];
// HACK - use the locale for the language
$language = Zend_Locale::getTranslation($langCode, 'language', $locale);
$language = Zend_Locale::getTranslation($langCode, 'language');
$region = Zend_Locale::getTranslation($regionCode, 'territory');
} else {
$region = '';
// HACK - use the locale for the language
$language = Zend_Locale::getTranslation($locale, 'language', $locale);
$language = Zend_Locale::getTranslation($locale, 'language');
}
if ($region != '') {
$region = " - $region";
}

// HACK - just return the language
// return ucfirst($language);
return ucfirst($language) . $region;
}

/**
* Convert a standard locale string (en_US) into the language and region.
*
* @param string $locale
* @return string
*/
function locale_human_ui($locale)
{
$parts = explode('_', $locale);
$langCode = $parts[0];
$language = Zend_Locale::getTranslation($langCode, 'language', $locale);
return ucfirst($language);
// return ucfirst($language) . $region;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions plugins/Multilanguage/views/shared/common/locale-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
<?php $country = $this->localeToCountry($locale); ?>
<li>
<?php if ($currentLocale == $locale): ?>
<span class="active flag-icon flag-icon-<?php echo strtolower($country); ?>"></span> <?php echo locale_human($locale); ?>
<span class="active flag-icon flag-icon-<?php echo strtolower($country); ?>"></span> <?php echo locale_human_ui($locale); ?>
<?php else: ?>
<?php $language = Zend_Locale::getTranslation(substr($locale, 0, 2), 'language'); ?>
<?php $url = url('setlocale', array('locale' => $locale, 'redirect' => $currentUrl) + $query); ?>
<a href="<?php echo $url ; ?>" title="<?php echo locale_human($locale); ?>"><span class="flag-icon flag-icon-<?php echo strtolower($country); ?>"></span> <?php echo locale_human($locale); ?></a>
<a href="<?php echo $url ; ?>" title="<?php echo locale_human_ui($locale); ?>"><span class="flag-icon flag-icon-<?php echo strtolower($country); ?>"></span> <?php echo locale_human_ui($locale); ?></a>
<?php endif; ?>
</li>
<?php endforeach; ?>
Expand Down

0 comments on commit d141b4e

Please sign in to comment.