-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade for Laravel 6 compatibility (#14)
* Adapt `str_` and `array_` helpers. * Rename public function `setUp()` to public function `setUp() void`. * Adapt dependencies to make tests pass from Laravel 5.1 to 6.0. * Debug app name for Laravel version < 5.3 to make tests pass. * Improve README.
- Loading branch information
1 parent
e0a793d
commit a9d8a43
Showing
11 changed files
with
79 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# [Translation.io](https://translation.io/laravel) client for Laravel 5 | ||
# [Translation.io](https://translation.io/laravel) client for Laravel 5/6 | ||
|
||
[](LICENSE.md) | ||
[](https://travis-ci.org/translation/laravel) | ||
|
@@ -301,10 +301,18 @@ Translation::setLocale('fr'); | |
|
||
## Testing | ||
|
||
To run the specs: | ||
To run the specs with oldest dependencies: | ||
|
||
```bash | ||
$ phpunit | ||
$ composer update --no-interaction --prefer-stable --prefer-lowest | ||
$ ./vendor/bin/phpunit | ||
``` | ||
|
||
To run the specs with latest dependencies: | ||
|
||
```bash | ||
$ composer update --no-interaction --prefer-stable | ||
$ ./vendor/bin/phpunit | ||
``` | ||
|
||
## Contributing | ||
|
@@ -346,9 +354,16 @@ Credits: [@deecewan](https://github.com/deecewan) | |
|
||
### Others | ||
|
||
If you want to create a new client for your favorite language or framework, feel | ||
free to reach us on [[email protected]](mailto:[email protected]) and | ||
we'll assist you with the workflow logic and send you API docs. | ||
If you want to create a new client for your favorite language or framework, please read our | ||
[Create a Translation.io Library](https://translation.io/docs/create-library) | ||
guide and use the special | ||
[init](https://translation.io/docs/create-library#initialization) and | ||
[sync](https://translation.io/docs/create-library#synchronization) endpoints. | ||
|
||
You can also use the more [traditional API](https://translation.io/docs/api). | ||
|
||
Feel free to contact us on [[email protected]](mailto:[email protected]) if | ||
you need some help or if you want to share your library. | ||
|
||
## License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,36 +160,36 @@ private function path() | |
} | ||
|
||
private function addStringsFromJsonFiles($translations) { | ||
$sourceStrings = []; | ||
$sourceStrings = []; | ||
|
||
// Load each JSON file to get source strings | ||
foreach ($this->JsonFiles() as $jsonFile) { | ||
$jsonTranslations = json_decode(file_get_contents($jsonFile), true); | ||
// Load each JSON file to get source strings | ||
foreach ($this->JsonFiles() as $jsonFile) { | ||
$jsonTranslations = json_decode(file_get_contents($jsonFile), true); | ||
|
||
foreach ($jsonTranslations as $key => $value) { | ||
$sourceStrings[] = $key; | ||
} | ||
} | ||
foreach ($jsonTranslations as $key => $value) { | ||
$sourceStrings[] = $key; | ||
} | ||
} | ||
|
||
// Deduplicate them (in a perfect world, each JSON locale file must have the same sources) | ||
$sourceStrings = array_unique($sourceStrings); | ||
// Deduplicate them (in a perfect world, each JSON locale file must have the same sources) | ||
$sourceStrings = array_unique($sourceStrings); | ||
|
||
// Insert them in $translations with a special context | ||
foreach ($sourceStrings as $sourceString) { | ||
$translations->insert($this->jsonStringContext(), $sourceString, ''); | ||
} | ||
// Insert them in $translations with a special context | ||
foreach ($sourceStrings as $sourceString) { | ||
$translations->insert($this->jsonStringContext(), $sourceString, ''); | ||
} | ||
} | ||
|
||
private function setPoHeaders($translations) { | ||
$translations->setHeader('Project-Id-Version', config('app.name')); | ||
$translations->setHeader('Report-Msgid-Bugs-To', '[email protected]'); | ||
$translations->setHeader("Plural-Forms", "nplurals=INTEGER; plural=EXPRESSION;"); | ||
|
||
// Only for testing (for VCR) | ||
if ($this->application->environment('testing')) { | ||
$translations->setHeader('POT-Creation-Date', '2018-01-01T12:00:00+00:00'); | ||
$translations->setHeader("PO-Revision-Date", "2018-01-02T12:00:00+00:00"); | ||
} | ||
$translations->setHeader('Project-Id-Version', $this->appName()); | ||
$translations->setHeader('Report-Msgid-Bugs-To', '[email protected]'); | ||
$translations->setHeader("Plural-Forms", "nplurals=INTEGER; plural=EXPRESSION;"); | ||
|
||
// Only for testing (for VCR) | ||
if ($this->application->environment('testing')) { | ||
$translations->setHeader('POT-Creation-Date', '2018-01-01T12:00:00+00:00'); | ||
$translations->setHeader("PO-Revision-Date", "2018-01-02T12:00:00+00:00"); | ||
} | ||
} | ||
|
||
private function mergeWithExistingTargetPoFile($translations, $target) { | ||
|
@@ -237,4 +237,14 @@ private function mergeWithExistingStringsFromTargetJsonFile($translations, $targ | |
private function jsonStringContext() { | ||
return 'Extracted from JSON file'; | ||
} | ||
|
||
private function appName() { | ||
$appName = 'Laravel'; | ||
|
||
if(config('app.name') != '') { | ||
$appName = config('app.name'); | ||
} | ||
|
||
return $appName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.