Skip to content

Commit

Permalink
Fixes #12 - fix multiple package translations bug
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jul 5, 2019
1 parent 81a8a2b commit 21fa942
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.6.7 (2018-07-05)
### Fixed
- Only one package added to the list of translations [#12](https://github.com/thepinecode/i18n/issues/12)

## v0.6.6 (2018-06-22)
### Fixed
- JS string conversions
Expand All @@ -10,15 +14,15 @@

## v0.6.4 (2018-06-13)
### Fixed
- add fallback for invalid translations
- add fallback for invalid translations [#11](https://github.com/thepinecode/i18n/issues/11)

## v0.6.3 (2018-06-07)
### Fixed
- trim whitespaces
- trim whitespaces [#10](https://github.com/thepinecode/i18n/issues/10)

## v0.6.2 (2018-06-03)
### Changed
- revert JS regexp to have better browser support
- revert JS regexp to have better browser support [#8](https://github.com/thepinecode/i18n/issues/8)

## v0.6.1 (2018-06-03)
### Fixed
Expand All @@ -27,7 +31,7 @@

## v0.6.0 (2018-06-02)
### Added
- support multilang applications and packages
- support multilang applications and packages [#7](https://github.com/thepinecode/i18n/issues/7)
- tests for multilang feature

## v0.5.1 (2018-05-29)
Expand Down
10 changes: 8 additions & 2 deletions src/I18nServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ protected function translations()
*/
protected function packageTranslations()
{
return collect($this->app['translator']->getLoader()->namespaces())->flatMap(function ($dir, $namespace) {
$namespaces = $this->app['translator']->getLoader()->namespaces();

return collect($namespaces)->map(function ($dir, $namespace) {
return collect(File::directories($dir))->flatMap(function ($dir) use ($namespace) {
return [
basename($dir) => collect([
Expand All @@ -89,7 +91,11 @@ protected function packageTranslations()
})->toArray(),
]),
];
});
})->toArray();
})->reduce(function ($collection, $item) {
return collect(array_merge_recursive($collection->toArray(), $item));
}, collect())->map(function ($item) {
return collect($item);
});
}

Expand Down
2 changes: 1 addition & 1 deletion tests/I18nTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function translations_can_be_printed_via_blade_directive()
/** @test */
public function translations_can_have_custom_key()
{
$this->get('/i18n/custom-key')->assertSee('window.custom = ');
$this->get('/i18n/custom-key')->assertSee("window['custom'] = ");
}

/** @test */
Expand Down

0 comments on commit 21fa942

Please sign in to comment.