Skip to content
Snippets Groups Projects
Commit e1cb4266 authored by Tilman Vatteroth's avatar Tilman Vatteroth :robot:
Browse files

init

parents
Branches
No related tags found
No related merge requests found
Showing
with 691 additions and 0 deletions
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace App\View;
use Cake\View\View;
/**
* App View class
*/
class AppView extends View
{
/**
* Initialization hook method.
*
* For e.g. use this method to load a helper for all views:
* `$this->loadHelper('Html');`
*
* @return void
*/
public function initialize()
{
}
}
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* PostsFixture
*
*/
class PostsFixture extends TestFixture
{
/**
* Fields
*
* @var array
*/
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
'name' => ['type' => 'integer', 'length' => 250, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'content' => ['type' => 'text', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
],
'_options' => [
'engine' => 'InnoDB',
'collation' => 'utf8_general_ci'
],
];
// @codingStandardsIgnoreEnd
/**
* Records
*
* @var array
*/
public $records = [
[
'id' => 1,
'name' => 1,
'content' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.'
],
];
}
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\PostsController;
use Cake\TestSuite\IntegrationTestCase;
/**
* App\Controller\PostsController Test Case
*/
class PostsControllerTest extends IntegrationTestCase
{
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.posts'
];
/**
* Test index method
*
* @return void
*/
public function testIndex()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test view method
*
* @return void
*/
public function testView()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test add method
*
* @return void
*/
public function testAdd()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test edit method
*
* @return void
*/
public function testEdit()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test delete method
*
* @return void
*/
public function testDelete()
{
$this->markTestIncomplete('Not implemented yet.');
}
}
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\PostsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\PostsTable Test Case
*/
class PostsTableTest extends TestCase
{
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.posts'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::exists('Posts') ? [] : ['className' => 'App\Model\Table\PostsTable'];
$this->Posts = TableRegistry::get('Posts', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->Posts);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
}
<?php
/**
* Test runner bootstrap.
*
* Add additional configuration/setup your application needs when running
* unit tests in this file.
*/
require dirname(__DIR__) . '/config/bootstrap.php';
Copyright (c) 2012, The Aura Project for PHP
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Default Installer for Aura System
=================================
Using this installer, all [Composer][] packages of `"type" : "aura-package"`
will be installed in the default location of
`vendor/vendor_name/package_name`.
Note that this is not an Aura package proper; it is designed for use directly
with Composer, and as such will be placed in `vendor` not `package`.
[Composer]: http://getcomposer.org/
[Aura system]: https://github.com/auraphp/system
{
"name": "aura/installer-default",
"version": "1.0.0",
"type": "composer-installer",
"license": "BSD-2-Clause",
"description": "Installs Aura packages using the Composer defaults.",
"keywords": ["aura", "installer"],
"authors": [
{
"name": "Paul M. Jones",
"email": "pmjones88@gmail.com",
"homepage": "http://paul-m-jones.com"
}
],
"autoload": {
"psr-0": {
"Aura\\Composer\\": "src/"
}
},
"extra" : {
"class" : "Aura\\Composer\\DefaultInstaller"
}
}
<?php
namespace Aura\Composer;
use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;
/**
*
* Really, we do nothing here, other than recognize `"type" : "aura-package".
* It installs like any other library package for Composer.
*
*/
class DefaultInstaller extends LibraryInstaller
{
/**
* {@inheritDoc}
*/
public function supports($packageType)
{
return $packageType == 'aura-package';
}
}
tests/tmp
\ No newline at end of file
language: php
php:
- 5.4
- 5.5
before_script:
- cd tests
script: phpunit
Copyright (c) 2011-2013, Aura for PHP
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aura.Intl
=========
[![Build Status](https://travis-ci.org/auraphp/Aura.Intl.png?branch=develop)](https://travis-ci.org/auraphp/Aura.Intl)
The Aura.Intl package provides internationalization (I18N) tools, specifically
package-oriented per-locale message translation.
This package is compliant with [PSR-0][], [PSR-1][], and [PSR-2][]. If you
notice compliance oversights, please send a patch via pull request.
[PSR-0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
[PSR-1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md
[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
Getting Started
===============
Instantiation
-------------
The easiest way to get started is to use the `scripts/instance.php` script to
instantiate a translator locator object.
```php
<?php
$translators = include '/path/to/Aura.Intl/scripts/instance.php';
?>
```
Alternatively, we can add the Aura.Intl package `/path/to/Aura.Intl/src` to
our autoloader and build a translator locator manually:
```php
<?php
use Aura\Intl\PackageLocator;
use Aura\Intl\FormatterLocator;
use Aura\Intl\TranslatorFactory;
use Aura\Intl\TranslatorLocator;
return new TranslatorLocator(
new PackageLocator,
new FormatterLocator([
'basic' => function() { return new Aura\Intl\BasicFormatter; },
'intl' => function() { return new Aura\Intl\IntlFormatter; },
]),
new TranslatorFactory,
'en_US'
);
?>
```
Setting Localized Messages For A Package
----------------------------------------
We can set localized messages for a package through the `PackageLocator` object
from the translator locator. We create a new `Package` with messages and place
it into the locator as a callable. The messages take the form of a message key and
and message string.
```php
<?php
use Aura\Intl\Package;
// get the package locator
$packages = $translators->getPackages();
// place into the locator for Vendor.Package
$packages->set('Vendor.Package', 'en_US', function() {
// create a US English message set
$package = new Package;
$package->setMessages([
'FOO' => 'The text for "foo."';
'BAR' => 'The text for "bar."';
]);
return $package;
});
// place into the locator for a Vendor.Package
$packages->set('Vendor.Package', 'pt_BR', function() {
// a Brazilian Portuguese message set
$package = new Package;
$package->setMessages([
'FOO' => 'O texto de "foo".';
'BAR' => 'O texto de "bar".';
]);
return $package;
});
?>
```
Setting The Default Locale
--------------------------
We can set the default locale for translations using the `setLocale()` method:
```php
<?php
$translators->setLocale('pt_BR');
?>
```
Getting A Localized Message
---------------------------
Now that the translator locator has messages and a default locale, we can get
an individual package translator. The package translator is suitable for
injection into another class, or for standalone use.
```php
<?php
// recall that the default locale is pt_BR
$translator = $translators->get('Vendor.Package');
echo $translator->translate('FOO'); // 'O texto de "foo".'
?>
```
You can get a translator for a non-default locale as well:
```php
<?php
$translator = $translators->get('Vendor.Package', 'en_US');
echo $translator->translate('FOO'); // 'The text for "foo."'
?>
```
Replacing Message Tokens With Values
------------------------------------
We often need to use dynamic values in translated messages. First, the
message string needs to have a token placeholder for the dynamic value:
```php
<?php
// get the packages out of the translator locator
$packages = $translators->getPackages();
$packages->set('Vendor.Dynamic', 'en_US', function() {
// US English messages
$package = new Package;
$package->setMessages([
'PAGE' => 'Page {page} of {pages} pages.';
]);
return $package;
});
$packages->set('Vendor.Dynamic', 'pt_BR', function() {
// Brazilian Portuguese messages
$package = new Package;
$package->setMessages([
'PAGE' => 'Página {page} de {pages} páginas.';
]);
return $package;
});
?>
```
Then, when we translate the message, we provide an array of tokens and
replacement values. These will be interpolated into the message string.
```php
<?php
// recall that the default locale is pt_BR
$translator = $translators->get('Vendor.Dynamic');
echo $translator->translate('PAGE', [
'page' => 1,
'pages' => 1,
]); // 'Página 1 de 1 páginas.'
?>
```
Pluralized Messages
-------------------
Usually, we need to use different messages when a value is singular or plural.
The `BasicFormatter` is not capable of presenting different messages based on
different token values. The `IntlFormatter` *is* capable, but the PHP
[`intl`](http://php.net/intl) extension must be loaded to take advantage of
it, and we must specify the `'intl'` formatter for the package in the catalog.
When using the `IntlFormatter`, we can build our message strings to present
singular or plural messages, as in the following example:
```php
<?php
// get the packages out of the translator locator
$packages = $translators->getCatalog();
// get the Vendor.Dynamic package en_US locale and set
// US English messages with pluralization. note the use
// of # instead of {pages} herein; using the placeholder
// "inside itself" with the Intl formatter causes trouble.
$package->setMessages([
'PAGE' => '{pages,plural,'
. '=0{No pages.}'
. '=1{One page only.}'
. 'other{Page {page} of # pages.}'
. '}'
]);
// use the 'intl' formatter for this package and locale
$package->setFormatter('intl');
// now that we have added the pluralizable messages,
// get the US English translator for the package
$translator = $translators->get('Vendor.Dynamic', 'en_US');
// zero translation
echo $translator->translate('PAGE', [
'page' => 0,
'pages' => 0,
]); // 'No pages.'
// singular translation
echo $translator->translate('PAGE', [
'page' => 1,
'pages' => 1,
]); // 'One page only.'
// plural translation
echo $translator->translate('PAGE', [
'page' => 3,
'pages' => 10,
]); // 'Page 3 of 10 pages.'
?>
```
Note that you can use other tokens within a pluralized token string to build
more complex messages. For more information, see the following:
<http://icu-project.org/apiref/icu4j/com/ibm/icu/text/MessageFormat.html>
- README examples for fallbacks
- README examples for all-at-once configuration
- More specific exception classes
* * *
- Rename "Catalog" to "Package"
- Rename "Package" to "PackageLocator"
- Create a Package description object that has properties for messages,
formatter, and fallback
- Create a PackageFactory
{
"name": "aura/intl",
"type": "aura-package",
"description": "The Aura.Intl package provides internationalization (I18N) tools, specifically\npackage-oriented per-locale message translation.",
"keywords": [
"intl",
"i18n",
"internationalization",
"l10n",
"localization",
"g11n",
"globalization"
],
"homepage": "http://auraphp.com/Aura.Intl",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Aura.Intl Contributors",
"homepage": "https://github.com/auraphp/Aura.Intl/contributors"
},
{
"name": "Paul M. Jones",
"email": "pmjones88@gmail.com",
"homepage": "http://paul-m-jones.com"
},
{
"name": "Pascal Borreli",
"email": "pascal@borreli.com"
},
{
"name": "Mapthegod",
"email": "mapthegod@gmail.com"
},
{
"name": "Jos\u00e9 Lorenzo Rodr\u00edguez",
"email": "jose.zap@gmail.com"
}
],
"require": {
"php": ">=5.4.0",
"aura/installer-default": "1.0.*"
},
"autoload": {
"psr-0": {
"Aura\\Intl": "src/"
},
"psr-4": {
"Aura\\Intl\\_Config\\": "config/"
}
},
"extra": {
"aura": {
"type": "library",
"config": {
"common": "Aura\\Intl\\_Config\\Common"
}
},
"branch-alias": {
"dev-develop": "1.1.x-dev"
}
},
"version": "1.1.1",
"time": "2014-08-24"
}
\ No newline at end of file
<?php
namespace Aura\Intl\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
public function define(Container $di)
{
/**
* Services
*/
$di->set('intl_package_factory', $di->lazyNew('Aura\Intl\PackageFactory'));
$di->set('intl_translator_locator', $di->lazyNew('Aura\Intl\TranslatorLocator'));
/**
* Aura\Intl\FormatterLocator
*/
$di->params['Aura\Intl\FormatterLocator']['registry'] = [
'basic' => $di->lazyNew('Aura\Intl\BasicFormatter'),
'intl' => $di->lazyNew('Aura\Intl\IntlFormatter'),
];
/**
* Aura\Intl\TranslatorLocator
*/
$di->params['Aura\Intl\TranslatorLocator'] = [
'locale' => 'en_US',
'factory' => $di->lazyNew('Aura\Intl\TranslatorFactory'),
'formatters' => $di->lazyNew('Aura\Intl\FormatterLocator'),
'packages' => $di->lazyNew('Aura\Intl\PackageLocator'),
];
}
public function modify(Container $di)
{
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment