Skip to content

Commit

Permalink
Corrigir grafia "1 periódicos" #58.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliano Maciel authored and Gustavo Fonseca committed Dec 14, 2018
1 parent 44ab995 commit 28e6ae8
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 6 deletions.
2 changes: 1 addition & 1 deletion application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('cookie', 'url', 'assets', 'text', 'twitter', 'language', 'pagination', 'phpmailer');
$autoload['helper'] = array('cookie', 'url', 'assets', 'text', 'twitter', 'language', 'pagination', 'phpmailer', 'pluralize');

/*
| -------------------------------------------------------------------
Expand Down
46 changes: 46 additions & 0 deletions application/helpers/pluralize_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* @author
* SciELO - Scientific Electronic Library Online
* @link
* https://www.scielo.org/
* @license
* Copyright SciELO All Rights Reserved.
*/

defined('BASEPATH') or exit('No direct script access allowed');

if (!function_exists('pluralize')) {

/**
* Pluralizes a word if quantity is not one.
* Based on a stackoverflow response https://stackoverflow.com/questions/1534127/pluralize-in-php.
*
* @param int $quantity Number of items
* @param string $singular Singular form of word
* @param string $plural Plural form of word; function will attempt to deduce plural form from singular if not provided
* @return string Pluralized word if quantity is not one, otherwise singular
*/
function pluralize($quantity, $singular, $plural = null)
{
if ($quantity == 1 || !strlen($singular)) {
return $singular;
}

if ($plural !== null) {
return $plural;
}

$last_letter = strtolower($singular[strlen($singular) - 1]);

switch ($last_letter) {
case 'y':
return substr($singular, 0, -1) . 'ies';
case 's':
return $singular . 'es';
default:
return $singular . 's';
}
}
}
1 change: 1 addition & 0 deletions application/language/english/scielo_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$lang['titles'] = 'titles';
$lang['articles'] = 'articles';
$lang['open_access'] = 'in open access';
$lang['journals_singular'] = 'journal';
$lang['journals'] = 'journals';
$lang['books'] = 'Books';
$lang['journals_list'] = 'Journals';
Expand Down
1 change: 1 addition & 0 deletions application/language/portuguese-brazilian/scielo_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$lang['titles'] = 'títulos';
$lang['articles'] = 'artigos';
$lang['open_access'] = 'em acesso aberto';
$lang['journals_singular'] = 'periódico';
$lang['journals'] = 'periódicos';
$lang['books'] = 'Livros';
$lang['journals_list'] = 'Periódicos';
Expand Down
1 change: 1 addition & 0 deletions application/language/spanish/scielo_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$lang['titles'] = 'títulos';
$lang['articles'] = 'artículos';
$lang['open_access'] = 'en acceso abierto';
$lang['journals_singular'] = 'revista';
$lang['journals'] = 'revistas';
$lang['books'] = 'Libros';
$lang['journals_list'] = 'Revistas';
Expand Down
8 changes: 4 additions & 4 deletions application/views/partials/collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<?php endif;?>
<a href="http://<?= $journal->domain ?>">
<h4><?= $journal->name[$lang_index] ?></h4>
<span><?php if ($has_journal_count) : ?><?= $journal->journal_count['current'] ?> <?= lang('journals') ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $journal->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
<span><?php if ($has_journal_count) : ?><?= $journal->journal_count['current'] ?> <?= pluralize($journal->journal_count['current'], lang('journals_singular'), lang('journals')) ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $journal->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
</a>
</dd>
<?php endforeach; ?>
Expand All @@ -38,7 +38,7 @@
<?php endif;?>
<a href="http://<?= $development->domain ?>">
<h4><?= $development->name[$lang_index] ?></h4>
<span><?php if ($has_journal_count) : ?><?= $development->journal_count['current'] ?> <?= lang('journals') ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $development->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
<span><?php if ($has_journal_count) : ?><?= $development->journal_count['current'] ?> <?= pluralize($development->journal_count['current'], lang('journals_singular'), lang('journals')) ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $development->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
</a>
</dd>
<?php endforeach; ?>
Expand All @@ -56,7 +56,7 @@
<?php endif;?>
<a href="http://<?= $discontinued->domain ?>">
<h4><?= $discontinued->name[$lang_index] ?></h4>
<span><?php if ($has_journal_count) : ?><?= $discontinued->journal_count['deceased'] ?> <?= lang('journals') ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $discontinued->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
<span><?php if ($has_journal_count) : ?><?= $discontinued->journal_count['deceased'] ?> <?= pluralize($discontinued->journal_count['deceased'], lang('journals_singular'), lang('journals')) ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $discontinued->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
</a>
</dd>
<?php endforeach; ?>
Expand Down Expand Up @@ -88,7 +88,7 @@
<?php endif;?>
<a href="http://<?= $other->domain ?>">
<h4><?= $other->name[$lang_index] ?></h4>
<span><?php if ($has_journal_count) : ?><?= $other->journal_count['current'] ?> <?= lang('journals') ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $other->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
<span><?php if ($has_journal_count) : ?><?= $other->journal_count['current'] ?> <?= pluralize($other->journal_count['current'], lang('journals_singular'), lang('journals')) ?><?php endif; ?> <?php if ($has_document_count) : ?><?= $other->document_count ?> <?= lang('articles') ?><?php endif; ?></span>
</a>
</dd>
<?php endforeach; ?>
Expand Down
5 changes: 4 additions & 1 deletion application/views/partials/journals-letter-filter.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
?>
<div class="btn-group-vertical btn-group-fixed" role="group" aria-label="...">
<?=create_letter_filter(current_url())?>
</div>
</div>
3 changes: 3 additions & 0 deletions application/views/partials/journals-search-form.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
?>
<form action="<?=current_url()?>">
<input type="hidden" name="limit" value="<?=$this->input->get('limit', true)?>">
<input type="hidden" name="letter" value="<?=$this->input->get('letter', true)?>">
Expand Down

0 comments on commit 28e6ae8

Please sign in to comment.