Skip to content

Commit

Permalink
Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kislota committed Aug 17, 2021
0 parents commit 8e95bcf
Show file tree
Hide file tree
Showing 65 changed files with 5,243 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/vendor
/tests/temp
composer.phar
composer.lock
.DS_Store
tests/temp/database.sqlite
.idea
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: php

php:
- 7.2
- 7.3

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- phpunit
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 WAAVI STUDIO SL

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.
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "waavi/translation",
"description": "A Translation package for Laravel 5 with database and cache support",
"keywords": [
"waavi",
"laravel-translator",
"laravel",
"translator",
"translation",
"localization"
],
"license": "MIT",
"authors": [
{
"name": "Waavi",
"email": "[email protected]",
"homepage": "http://waavi.com"
}
],
"require": {
"laravel/framework": "^6.0|^7.0|^8.0",
"doctrine/dbal": "^2.5"
},
"require-dev": {
"phpunit/phpunit" : "^9.1",
"orchestra/testbench": "~6.0",
"mockery/mockery": "^1.3.0"
},
"autoload": {
"psr-4": {
"Waavi\\Translation\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Waavi\\Translation\\Test\\": "tests"
}
},
"minimum-stability": "dev",
"scripts": {
"test": "vendor/bin/phpunit"
}
}
Empty file added config/.gitkeep
Empty file.
51 changes: 51 additions & 0 deletions config/translator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Default Translation Mode
|--------------------------------------------------------------------------
|
| This option controls the translation's bundle mode of operation.
|
| Supported:
|
| 'mixed' Both files and the database are queried for language entries, with files taking priority.
| 'mixed_db' Both files and the database are queried for language entries, with database taking priority.
| 'database' Use the database as the exclusive source for language entries.
| 'files' Use files as the exclusive source for language entries [Laravel's default].
*/
'source' => env('TRANSLATION_SOURCE', 'files'),

/*
|--------------------------------------------------------------------------
| Default Translation Connection
|--------------------------------------------------------------------------
|
| This option controls the translation's connection. By default is use Laravel default connection. In most cases
| you don't need to change it.
*/
'connection' => config('database.default', env('TRANSLATOR_CONNECTION', 'mysql')),

// In case the files source is selected, please enter here the supported locales for your app.
// Ex: ['en', 'es', 'fr']
'available_locales' => [],

/*
|--------------------------------------------------------------------------
| Default Translation Cache
|--------------------------------------------------------------------------
|
| Choose whether to leverage Laravel's cache module and how to do so.
|
| 'enabled' Boolean value.
| 'timeout' In minutes.
|
*/
'cache' => [
'enabled' => env('TRANSLATION_CACHE_ENABLED', true),
'timeout' => env('TRANSLATION_CACHE_TIMEOUT', 60),
'suffix' => env('TRANSLATION_CACHE_SUFFIX', 'translation'),
],
];
Empty file added database/migrations/.gitkeep
Empty file.
34 changes: 34 additions & 0 deletions database/migrations/2013_07_25_145943_create_languages_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;

class CreateLanguagesTable extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection(config('translator.connection'))->create('translator_languages', function ($table) {
$table->increments('id');
$table->string('locale', 6)->unique();
$table->string('name', 60)->unique();
$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('translator_languages');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;

class CreateTranslationsTable extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection(config('translator.connection'))->create('translator_translations', function ($table) {
$table->increments('id');
$table->string('locale', 6);
$table->string('namespace', 150)->default('*');
$table->string('group', 150);
$table->string('item', 150);
$table->text('text');
$table->boolean('unstable')->default(false);
$table->boolean('locked')->default(false);
$table->timestamps();
$table->foreign('locale')->references('locale')->on('translator_languages');
$table->unique(['locale', 'namespace', 'group', 'item']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('translator_translations');
}
}
33 changes: 33 additions & 0 deletions database/migrations/2016_06_02_124154_increase_locale_length.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;

class IncreaseLocaleLength extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection(config('translator.connection'))->table('translator_languages', function ($table) {
$table->string('locale', 10)->change();
});
Schema::connection(config('translator.connection'))->table('translator_translations', function ($table) {
$table->string('locale', 10)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}

}
20 changes: 20 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Translation Test Suite">
<directory suffix=".php">./tests/</directory>
<exclude>/temp</exclude>
<exclude>/lang</exclude>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 8e95bcf

Please sign in to comment.