Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom directives when updating blade templates #41

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":1240:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:21:{s:31:"LaravelGettextTest::testAdapter";d:0.13;s:33:"LaravelGettextTest::testSetLocale";d:0.005;s:33:"LaravelGettextTest::testGetLocale";d:0.005;s:41:"LaravelGettextTest::testIsLocaleSupported";d:0.006;s:32:"LaravelGettextTest::testToString";d:0.007;s:35:"LaravelGettextTest::testGetEncoding";d:0.006;s:35:"LaravelGettextTest::testSetEncoding";d:0.006;s:43:"MultipleDomainTest::testDomainConfiguration";d:0.006;s:43:"MultipleDomainTest::testFrontendDomainPaths";d:0.006;s:42:"MultipleDomainTest::testBackendDomainPaths";d:0.005;s:42:"MultipleDomainTest::testDefaultDomainPaths";d:0.005;s:44:"MultipleDomainTest::testNoMissingDomainPaths";d:0.005;s:36:"MultipleDomainTest::testCompileViews";d:0.018;s:34:"MultipleDomainTest::testFileSystem";d:0.021;s:39:"MultipleDomainTest::testGetRelativePath";d:0.006;s:38:"unit\TranslationTest::testCompileViews";d:0.039;s:43:"unit\TranslationTest::testFrenchTranslation";d:0.009;s:54:"unit\TranslationTest::testFrenchTranslationReplacement";d:0.004;s:53:"unit\TranslationTest::testFrenchTranslationPluralNone";d:0.006;s:52:"unit\TranslationTest::testFrenchTranslationPluralOne";d:0.006;s:57:"unit\TranslationTest::testFrenchTranslationPluralMultiple";d:0.004;}}}
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@

*Laravel Gettext* is a package compatible with the great Laravel PHP Framework. It provides a simple way to add localization support to Laravel applications. It is designed to work with *GNU gettext* and *Poedit*. Former versions of this package (before 4.x) works with the native php-gettext module. Current versions uses the Symfony translation package by default instead of native php extension.

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=7.2.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 6 stable release (7.2.0)](https://github.com/zerospam/laravel-gettext/tree/7.2.0)
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=7.3.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 7 stable release (7.3.0)](https://github.com/zerospam/laravel-gettext/tree/7.3.0)

> Note: This documentation applies to laravel 5.5.x and up. For older versions of laravel check the following links:

### Older versions
[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=7.1.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 5.6.x & 5.7.x stable release (7.1.0)](https://github.com/zerospam/laravel-gettext/tree/7.0.0)
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=7.2.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 6 stable release (7.2.0)](https://github.com/zerospam/laravel-gettext/tree/7.2.0)

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=6.1.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 5.5.x stable release (6.1.0)](https://github.com/zerospam/laravel-gettext/tree/6.1.0)
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=7.1.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 5.6.x & 5.7.x stable release (7.1.0)](https://github.com/zerospam/laravel-gettext/tree/7.0.0)

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=5.0.2)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/5.0.2">Latest Laravel 5.4.x stable release (5.0.2)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=6.1.0)](https://travis-ci.org/zerospam/laravel-gettext) [Latest Laravel 5.5.x stable release (6.1.0)](https://github.com/zerospam/laravel-gettext/tree/6.1.0)

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=4.0.4)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/4.0.4">Latest Laravel 5.3.x stable release (4.0.4)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=5.0.2)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/5.0.2">Latest Laravel 5.4.x stable release (5.0.2)</a>

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=3.1.0)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/3.1.0">Latest Laravel 5.2.x stable release (3.1.0)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=4.0.4)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/4.0.4">Latest Laravel 5.3.x stable release (4.0.4)</a>

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=3.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/3.0.3">Latest Laravel 5.1.x stable release (3.0.3)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=3.1.0)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/3.1.0">Latest Laravel 5.2.x stable release (3.1.0)</a>

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=2.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/2.0.3">Latest Laravel 5.0 stable release (2.0.3)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=3.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/3.0.3">Latest Laravel 5.1.x stable release (3.0.3)</a>

[![Stable build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=1.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/1.0.3">Latest Laravel 4.x stable release (1.0.3)</a>
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=2.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/2.0.3">Latest Laravel 5.0 stable release (2.0.3)</a>

[![Dev build Status](https://travis-ci.org/zerospam/laravel-gettext.png?branch=master)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/master">Development master</a> Unstable, only for development (dev-master)
[![Stable build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=1.0.3)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/1.0.3">Latest Laravel 4.x stable release (1.0.3)</a>

[![Dev build Status](https://travis-ci.org/deepskylog/laravel-gettext.png?branch=master)](https://travis-ci.org/zerospam/laravel-gettext) <a href="https://github.com/zerospam/laravel-gettext/tree/master">Development master</a> Unstable, only for development (dev-master)

### 1. Requirements

Expand Down Expand Up @@ -56,7 +58,7 @@ Optional requirements if you want to use the native php-gettext extension:
Add the composer repository to your *composer.json* file:

```json
"zerospam/laravel-gettext": "6.x"
"deepskylog/laravel-gettext": "7.x"
```

And run composer update. Once it's installed, laravel will discover automatically the provider and load it. (Only for 5.5)
Expand All @@ -75,7 +77,7 @@ You also need to register the LaravelGettext middleware in the ```app/Http/Kerne
protected $middlewareGroups = [
'web' => [
// ...
\Xinax\LaravelGettext\Middleware\GettextMiddleware::class,
\deepskylog\LaravelGettext\Middleware\GettextMiddleware::class,
],
// ...
]
Expand Down Expand Up @@ -440,7 +442,7 @@ Also, if you're using Symfony as your backend, you can add the `_s` method. It's
* The "_n" and "ngettext" are plural translation functions
* The "dgettext" function allows a translation domain to be explicitly specified
*
* "__" and "_n" and "_i" and "_s" are helpers functions @see \Xinax\LaravelGettext\Support\helpers.php
* "__" and "_n" and "_i" and "_s" are helpers functions @see \deepskylog\LaravelGettext\Support\helpers.php
*/
'keywords-list' => ['_', '__', '_i', '_s', 'gettext', '_n:1,2', 'ngettext:1,2', 'dgettext:2'],;
```
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zerospam/laravel-gettext",
"name": "deepskylog/laravel-gettext",
"description": "Adds localization support to laravel applications in an easy way using Poedit and GNU gettext.",
"homepage": "https://github.com/zerospam/laravel-gettext",
"homepage": "https://github.com/deepskylog/laravel-gettext",
"keywords": [
"gettext",
"localization",
Expand All @@ -18,10 +18,14 @@
{
"name": "Antoine Aflalo",
"email": "[email protected]"
},
{
"name": "Wim De Meester",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/zerospam/laravel-gettext/issues"
"issues": "https://github.com/deepskylog/laravel-gettext/issues"
},
"require": {
"php": ">=7.2",
Expand All @@ -37,17 +41,17 @@
},
"autoload": {
"psr-0": {
"Xinax\\LaravelGettext\\": "src/"
"deepskylog\\LaravelGettext\\": "src/"
},
"files": [
"src/Xinax/LaravelGettext/Support/helpers.php"
"src/deepskylog/LaravelGettext/Support/helpers.php"
]
},
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"Xinax\\LaravelGettext\\LaravelGettextServiceProvider"
"deepskylog\\LaravelGettext\\LaravelGettextServiceProvider"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true" addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/Xinax/</directory>
<directory suffix=".php">./src/deepskylog/</directory>
</whitelist>
</filter>
<logging>
Expand Down
56 changes: 27 additions & 29 deletions src/config/config.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php


return [

/**
* Translation handlers, options are:
* Translation handlers, options are:.
*
* - symfony: (recommended) uses the symfony translations component. Incompatible with php-gettext
* you must uninstall the php-gettext module before use this handler.
Expand All @@ -25,7 +23,7 @@
'locale' => 'en_US',

/**
* Supported locales: An array containing all allowed languages
* Supported locales: An array containing all allowed languages.
*/
'supported-locales' => [
'en_US',
Expand All @@ -40,43 +38,43 @@
* -----------------------------------------------------------------------
* All standard configuration ends here. The following values
* are only for special cases.
* -----------------------------------------------------------------------
* -----------------------------------------------------------------------.
**/

/**
* Locale categories to set
* Locale categories to set.
*/
'categories' => [
'LC_ALL',
],

/**
* Base translation directory path (don't use trailing slash)
* Base translation directory path (don't use trailing slash).
*/
'translations-path' => '../resources/lang',

/**
* Relative path to the app folder: is used on .po header files
* Relative path to the app folder: is used on .po header files.
*/
'relative-path' => '../../../../../app',

/**
* Fallback locale: When default locale is not available
* Fallback locale: When default locale is not available.
*/
'fallback-locale' => 'en_US',

/**
* Default domain used for translations: It is the file name for .po and .mo files
* Default domain used for translations: It is the file name for .po and .mo files.
*/
'domain' => 'messages',

/**
* Project name: is used on .po header files
* Project name: is used on .po header files.
*/
'project' => 'MultilanguageLaravelApplication',

/**
* Translator contact data (used on .po headers too)
* Translator contact data (used on .po headers too).
*/
'translator' => 'James Translator <[email protected]>',

Expand All @@ -95,25 +93,25 @@
/**
* Multi-domain directory paths. If you want the translations in
* different files, just wrap your paths into a domain name.
* for example:
* for example:.
*/
/*
'source-paths' => [

// 'frontend' domain
'frontend' => [
'controllers',
'views/frontend',
],
'controllers',
'views/frontend',
],

// 'backend' domain
'backend' => [
'views/backend',
],
'backend' => [
'views/backend',
],

// 'messages' domain (matches default domain)
'storage/views',
],
'storage/views',
],
*/

/**
Expand All @@ -123,33 +121,33 @@
'sync-laravel' => true,

/**
* The adapter used to sync the laravel built-in locale
* The adapter used to sync the laravel built-in locale.
*/
'adapter' => \Xinax\LaravelGettext\Adapters\LaravelAdapter::class,
'adapter' => \deepskylog\LaravelGettext\Adapters\LaravelAdapter::class,

/**
* Where to store the current locale/domain
* Where to store the current locale/domain.
*
* By default, in the session.
* Can be changed for only memory or your own storage mechanism
*
* @see \Xinax\LaravelGettext\Storages\Storage
* @see \deepskylog\LaravelGettext\Storages\Storage
*/
'storage' => \Xinax\LaravelGettext\Storages\SessionStorage::class,
'storage' => \deepskylog\LaravelGettext\Storages\SessionStorage::class,

/**
* Use custom locale that is not supported by the system
* Use custom locale that is not supported by the system.
*/
'custom-locale' => false,

/**
* The keywords list used by poedit to search the strings to be translated
* The keywords list used by poedit to search the strings to be translated.
*
* The "_", "__" and "gettext" are singular translation functions
* The "_n" and "ngettext" are plural translation functions
* The "dgettext" function allows a translation domain to be explicitly specified
*
* "__" and "_n" and "_i" and "_s" are helpers functions @see \Xinax\LaravelGettext\Support\helpers.php
* "__" and "_n" and "_i" and "_s" are helpers functions @see \deepskylog\LaravelGettext\Support\helpers.php
*/
'keywords-list' => ['_', '__', '_i', '_s', 'gettext', '_n:1,2', 'ngettext:1,2', 'dgettext:2'],
];
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?php

namespace Xinax\LaravelGettext\Adapters;
namespace deepskylog\LaravelGettext\Adapters;

interface AdapterInterface
{
/**
* Get the current locale
* Get the current locale.
*
* @return string
*/
public function getLocale();

/**
* Sets the locale on the adapter
* Sets the locale on the adapter.
*
* @param string $locale
* @param string $locale
* @return boolean
*/
public function setLocale($locale);

/**
* Get the application path
* Get the application path.
*
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php

namespace Xinax\LaravelGettext\Adapters;
namespace deepskylog\LaravelGettext\Adapters;

use Illuminate\Support\Facades\App;

class LaravelAdapter implements AdapterInterface
{
/**
* Set current locale
* Set current locale.
*
* @param string $locale
* @param string $locale
* @return bool
*/
public function setLocale($locale)
{
App::setLocale(substr($locale, 0, 2));

return true;
}

/**
* Get the locale
* Get the locale.
*
* @return string
*/
Expand All @@ -29,7 +30,7 @@ public function getLocale()
}

/**
* Get the application path
* Get the application path.
*
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
<?php

namespace Xinax\LaravelGettext\Commands;
namespace deepskylog\LaravelGettext\Commands;

use Illuminate\Console\Command;
use Xinax\LaravelGettext\FileSystem;
use Xinax\LaravelGettext\Config\ConfigManager;
use deepskylog\LaravelGettext\FileSystem;
use deepskylog\LaravelGettext\Config\ConfigManager;

class BaseCommand extends Command
{
/**
* Filesystem helper
* Filesystem helper.
*
* @var \Xinax\LaravelGettext\FileSystem
* @var \deepskylog\LaravelGettext\FileSystem
*/
protected $fileSystem;

/**
* Package configuration data
* Package configuration data.
*
* @var array
*/
protected $configuration;

/**
* Prepares the package environment for gettext commands
*
* @return void
* Prepares the package environment for gettext commands.
*
*/
protected function prepare()
{
$configManager = ConfigManager::create();

$this->fileSystem = new FileSystem(
$configManager->get(),
app_path(),
Expand Down
Loading