Skip to content

Commit

Permalink
Version 0.9 Released
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Pratt committed Sep 23, 2013
0 parents commit 594e2c6
Show file tree
Hide file tree
Showing 18 changed files with 982 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
.DS_Store
vendor/*
Docs/*
Tests/Coverage
composer.lock
composer.phar
25 changes: 25 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,25 @@
filter:
excluded_paths:
- 'vendor/*'
- 'Tests/*'
paths:
- Lib/
tools:
php_cpd:
filter:
excluded_paths: ['vendor/*', 'Tests/*']
php_pdepend:
excluded_dirs:
1: 'Tests/*'
php_mess_detector:
filter:
excluded_paths: ['vendor/*', 'Tests/*']
sensiolabs_security_checker:
filter:
excluded_paths: ['vendor/*', 'Tests/*']
php_code_coverage:
filter:
excluded_paths: ['vendor/*', 'Tests/*']
php_loc:
excluded_dirs:
- 'Tests/*'
6 changes: 6 additions & 0 deletions .travis.yml
@@ -0,0 +1,6 @@
language: php

php:
- 5.3
- 5.4
- 5.5
20 changes: 20 additions & 0 deletions LICENSE
@@ -0,0 +1,20 @@
MIT LICENSE
Copyright (C) 2013 by Michael Pratt <pratt@hablarmierda.net>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
72 changes: 72 additions & 0 deletions Lib/RelativeTime/Adapters/Language.php
@@ -0,0 +1,72 @@
<?php
/**
* Language.php
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @link http://www.michael-pratt.com/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace RelativeTime\Adapters;

/**
* Abstract class for language definitions.
* It basically gives the option to use an object
* as as an array.
*/
abstract class Language implements \ArrayAccess
{
protected $strings = array();

/**
* Sets a parameter
*
* @param string $id
* @param string $value
*/
public function offsetSet($id, $value) { $this->strings[$id] = $value; }

/**
* Gets a parameter
*
* @param string $id
* @return string
*
* @throws InvalidArgumentException if the id is not defined
*/
public function offsetGet($id)
{
if (!array_key_exists($id, $this->strings))
throw new \InvalidArgumentException($id . ' is not defined');

return $this->strings[$id];
}

/**
* Checks if a parameter is set.
*
* @param string $id
* @return bool
*/
public function offsetExists($id) { return array_key_exists($id, $this->strings); }

/**
* Unsets a parameter
*
* @param string $id
* @return void
*/
public function offsetUnset($id) { unset($this->strings[$id]); }

/**
* Returns all defined keys
*
* @return array
*/
public function keys() { return array_keys($this->strings); }
}

?>
22 changes: 22 additions & 0 deletions Lib/RelativeTime/Autoload.php
@@ -0,0 +1,22 @@
<?php
/**
* Autoload.php
* The RelativeTime Autoloader, to be used when there is no composer around.
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @link http://www.michael-pratt.com/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (function_exists('spl_autoload_register'))
{
spl_autoload_register(function ($class) {
$class = __DIR__ . '/' . str_replace('\\', DIRECTORY_SEPARATOR, str_ireplace('RelativeTime\\', '', $class)) . '.php';
if (file_exists($class))
require $class;
});
}

?>
51 changes: 51 additions & 0 deletions Lib/RelativeTime/Languages/English.php
@@ -0,0 +1,51 @@
<?php
/**
* English.php
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @link http://www.michael-pratt.com/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace RelativeTime\Languages;

/**
* English Translation
*/
class English extends \RelativeTime\Adapters\Language
{
protected $strings = array(
'now' => 'just now',
'ago' => '%s ago',
'left' => '%s left',
'seconds' => array(
'plural' => '%d seconds',
'singular' => '%d second',
),
'minutes' => array(
'plural' => '%d minutes',
'singular' => '%d minute',
),
'hours' => array(
'plural' => '%d hours',
'singular' => '%d hour',
),
'days' => array(
'plural' => '%d days',
'singular' => '%d day',
),
'months' => array(
'plural' => '%d months',
'singular' => '%d month',
),
'years' => array(
'plural' => '%d years',
'singular' => '%d year',
),
);
}

?>
51 changes: 51 additions & 0 deletions Lib/RelativeTime/Languages/German.php
@@ -0,0 +1,51 @@
<?php
/**
* German.php
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @link http://www.michael-pratt.com/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace RelativeTime\Languages;

/**
* German Translation
*/
class German extends \RelativeTime\Adapters\Language
{
protected $strings = array(
'now' => 'just now',
'ago' => 'vor %s',
'left' => '%s nach',
'seconds' => array(
'plural' => '%d Sekunden',
'singular' => '%d Sekunde',
),
'minutes' => array(
'plural' => '%d Minuten',
'singular' => '%d Minute',
),
'hours' => array(
'plural' => '%d Stunden',
'singular' => '%d Stunde',
),
'days' => array(
'plural' => '%d Tage',
'singular' => '%d Tag',
),
'months' => array(
'plural' => '%d Monaten',
'singular' => '%d Monat',
),
'years' => array(
'plural' => '%d Jahren',
'singular' => '%d Jahr',
),
);
}

?>
51 changes: 51 additions & 0 deletions Lib/RelativeTime/Languages/Spanish.php
@@ -0,0 +1,51 @@
<?php
/**
* Spanish.php
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @link http://www.michael-pratt.com/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace RelativeTime\Languages;

/**
* Spanish Translation
*/
class Spanish extends \RelativeTime\Adapters\Language
{
protected $strings = array(
'now' => 'justo ahora',
'ago' => 'hace %s',
'left' => 'faltan %s',
'seconds' => array(
'plural' => '%d segundos',
'singular' => '%d segundo',
),
'minutes' => array(
'plural' => '%d minutos',
'singular' => '%d minuto',
),
'hours' => array(
'plural' => '%d horas',
'singular' => '%d hora',
),
'days' => array(
'plural' => '%d dias',
'singular' => '%d dia',
),
'months' => array(
'plural' => '%d meses',
'singular' => '%d mes',
),
'years' => array(
'plural' => '%d años',
'singular' => '%d año',
),
);
}

?>

0 comments on commit 594e2c6

Please sign in to comment.