Skip to content

feat: allow only/except overrides on @translations and Update deprecated GitHub Actions to fix failing CI - #53

Merged
GENL merged 6 commits into
GENL:1.xfrom
vpuentem:feature/dynamic-namespace-filtering
Jul 30, 2026
Merged

feat: allow only/except overrides on @translations and Update deprecated GitHub Actions to fix failing CI#53
GENL merged 6 commits into
GENL:1.xfrom
vpuentem:feature/dynamic-namespace-filtering

Conversation

@vpuentem

@vpuentem vpuentem commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements dynamic namespace filtering for #27 by allowing optional only / except overrides on the @translations directive, so different Blade layouts can load different translation subsets without changing global config.

@translations(app()->getLocale(), [
    'only' => ['dashboard', 'public'],
    'except' => ['admin'],
])
  • Existing @translations / @translations($locale) usage is unchanged
  • Short names resolve under the loaded locale(s); full paths like en/auth still work
  • When an options key is present, it replaces the matching config value for that render
  • When options are passed, the shared generated translations cache file is skipped (filters are layout-specific)

Test plan

  • vendor/bin/phpunit (13 tests)
  • Short-name only / except
  • Options override config; absent keys fall back to config
  • Full paths still work
  • Options disable cache path
  • Blade compile output for BC + options form

Support per-layout namespace filtering via an optional options
array so apps can ship different translation subsets per root
layout without changing global config. Closes GENL#27.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vpuentem
vpuentem changed the base branch from master to 1.x July 21, 2026 19:36
Comment thread src/BladeTranslationsGenerator.php Outdated
Comment thread src/Helpers.php
Comment thread src/Helpers.php
Comment on lines +175 to +176
$namespace = str_replace('\\', '/', trim((string) $namespace, '/\\'));
$namespace = Str::beforeLast($namespace, '.');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are duplicated in namespaceToDotPath. But it's an ok tradeoff for now.

Comment thread src/Helpers.php
Comment on lines +182 to +195
// Full path when the first segment is a locale key (e.g. "en/auth").
// Otherwise treat as a short name and expand under each loaded locale.
$firstSegment = Str::before($namespace, '/');

if (isset($translations[$firstSegment])) {
$resolved[] = $namespace;
continue;
}

foreach ($localeKeys as $locale) {
if (isset($translations[$locale])) {
$resolved[] = $locale . '/' . $namespace;
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Comment thread src/BladeTranslationsGenerator.php Outdated
@GENL

GENL commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Thanks for this awesome work @vpuentem. I left a few quick comments. After that the PR should be ready to merge.

vpuentem and others added 3 commits July 28, 2026 17:51
Co-authored-by: GENL <36866702+GENL@users.noreply.github.com>
Co-authored-by: GENL <36866702+GENL@users.noreply.github.com>
Co-authored-by: GENL <36866702+GENL@users.noreply.github.com>
@vpuentem

Copy link
Copy Markdown
Contributor Author

Thanks for this awesome work @vpuentem. I left a few quick comments. After that the PR should be ready to merge.

Hey @GENL, thanks for the review!

Already adressed the actionable comments, let me know if you need me to modify anything, thanks in advance!

actions/cache@v1 was disabled by GitHub, which broke the
Tests workflow. Bumped it to v4, and updated actions/checkout and
actions/setup-node to their latest major versions too since the old
ones are on the same deprecation track.
@GENL GENL changed the title feat: allow only/except overrides on @translations feat: allow only/except overrides on @translations and Fix deprecated GitHub Actions to fix failing CI Jul 30, 2026
@GENL GENL changed the title feat: allow only/except overrides on @translations and Fix deprecated GitHub Actions to fix failing CI feat: allow only/except overrides on @translations and Update deprecated GitHub Actions to fix failing CI Jul 30, 2026
@GENL
GENL merged commit e296770 into GENL:1.x Jul 30, 2026
15 checks passed
@GENL GENL mentioned this pull request Jul 30, 2026
@GENL GENL linked an issue Jul 30, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic namespace filtering

2 participants