Skip to content

Commit

Permalink
NEPT-1804: Use the translated path of a content if exists. (#13)
Browse files Browse the repository at this point in the history
* NEPT-1804: Use the translated path of a content if exists.

* NEPT-1804: Add missing param doc in _ec_resp_nexteuropa_multilingual_language_list_column().

* NEPT-1804: $all_paths[$language->language] is set.
  • Loading branch information
ku-enza authored Feb 21, 2018
1 parent b90fcfb commit 3e99e7a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,8 @@ function ec_resp_nexteuropa_multilingual_language_list(array $variables) {
$first_half = array_slice($variables['languages'], 0, $half);
$second_half = array_slice($variables['languages'], $half);

$content .= _ec_resp_nexteuropa_multilingual_language_list_column($first_half, $variables['path'], $options);
$content .= _ec_resp_nexteuropa_multilingual_language_list_column($second_half, $variables['path'], $options);
$content .= _ec_resp_nexteuropa_multilingual_language_list_column($first_half, $variables['path'], $options, $variables['all_paths']);
$content .= _ec_resp_nexteuropa_multilingual_language_list_column($second_half, $variables['path'], $options, $variables['all_paths']);

$content .= '</div>';

Expand All @@ -1786,18 +1786,28 @@ function ec_resp_nexteuropa_multilingual_language_list(array $variables) {
* The internal path being linked to.
* @param array $options
* An associative array of additional options.
* @param array $all_paths
* An associative array of paths keyed by their language code.
* If it is not empty, the array items will be used to generate the links of
* language list.
*
* @return string
* Formatted HTML column displaying the list of provided languages.
*/
function _ec_resp_nexteuropa_multilingual_language_list_column($languages, $path, $options) {
function _ec_resp_nexteuropa_multilingual_language_list_column($languages, $path, $options, $all_paths = array()) {
$content = '<div class="col-sm-6">';
foreach ($languages as $language) {
$options['attributes']['lang'] = $language->language;
$options['attributes']['hreflang'] = $language->language;
$options['attributes']['class'] = 'btn splash-page__btn-language';
$options['language'] = $language;
$content .= l($language->native, $path, $options);

$translated_path = $path;
if (!empty($all_paths[$language->language])) {
$translated_path = $all_paths[$language->language];
}

$content .= l($language->native, $translated_path, $options);
}
$content .= '</div>';

Expand Down

0 comments on commit 3e99e7a

Please sign in to comment.