Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.3, 8.4]
php: [8.3, 8.4, 8.5]
phpunit: ['12.5.0', '12.5.8']
stability: [prefer-lowest, prefer-stable]
exclude:
- php: 8.3
phpunit: '12.0.0'
- php: 8.4
phpunit: '12.0.0'
- php: 8.5
phpunit: '12.0.0'

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }}

Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"

- name: Execute tests
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
run: vendor/bin/phpunit
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USERNAME: root
Expand All @@ -89,14 +91,16 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.3, 8.4]
php: [8.3, 8.4, 8.5]
phpunit: ['12.5.0', '12.5.8']
stability: [prefer-lowest, prefer-stable]
exclude:
- php: 8.3
phpunit: '12.0.0'
- php: 8.4
phpunit: '12.0.0'
- php: 8.5
phpunit: '12.0.0'

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }} - Windows

Expand Down
16 changes: 13 additions & 3 deletions src/Phaseolies/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ protected function getLine($namespace, $group, $locale, $item, array $replace)
$this->loadTranslations($namespace, $group, $locale);

$keys = explode('.', $item);
$line = $this->loaded[$namespace][$group][$locale] ?? null;

$namespaceKey = $namespace ?? '';
$groupKey = $group ?? '';

$line = $this->loaded[$namespaceKey][$groupKey][$locale] ?? null;

foreach ($keys as $key) {
if (!is_array($line)) {
Expand Down Expand Up @@ -225,7 +229,10 @@ public function loadTranslations($namespace, $group, $locale)

$lines = $this->loader->load($locale, $group, $namespace);

$this->loaded[$namespace][$group][$locale] = $lines;
$namespaceKey = $namespace ?? '';
$groupKey = $group ?? '';

$this->loaded[$namespaceKey][$groupKey][$locale] = $lines;
}

/**
Expand All @@ -238,7 +245,10 @@ public function loadTranslations($namespace, $group, $locale)
*/
protected function isLoaded($namespace, $group, $locale)
{
return isset($this->loaded[$namespace][$group][$locale]);
$namespaceKey = $namespace ?? '';
$groupKey = $group ?? '';

return isset($this->loaded[$namespaceKey][$groupKey][$locale]);
}

/**
Expand Down
Loading