Skip to content

feat: modernize Jigsaw localization package - #10

Merged
vitormattos merged 49 commits into
mainfrom
feat/translation-catalog-foundation
Sep 28, 2026
Merged

vitormattos merged 49 commits into
mainfrom
feat/translation-catalog-foundation

Conversation

@vitormattos

@vitormattos vitormattos commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Modernizes the Jigsaw localization package and moves the maintained fork to the LibreSign package identity.

Breaking changes

  • Composer package: elaborate-code/jigsaw-localization → libresign/jigsaw-localization
  • PHP namespace: ElaborateCode\JigsawLocalization → LibreSign\JigsawLocalization
  • minimum PHP version: 8.3

This should be released as a new major version.

Main changes

  • generic extraction pipeline with source-locale filtering;
  • deterministic JSON catalog read/write, synchronization and validation;
  • injectable LocalizationLoader contract;
  • internal strict JSON directory loader replacing the abandoned php-json-tongue dependency;
  • compatibility with per-locale directories and legacy multi/ catalogs;
  • focused locale/path, catalog, placeholder and extraction services;
  • isolated PHPUnit, PHPStan, PHPMD and Pint environments with Composer Bin Plugin;
  • Dependabot for Composer and GitHub Actions;
  • explicit MIT license, focused README and separate contribution guide.

The README keeps attribution to the original elaborate-code/jigsaw-localization project.

Reusability

The package contains no LibreSign-specific translation rules or translation-platform integration. Jigsaw projects can use the default JSON loader, inject another storage backend, plug in custom string extractors, or consume the catalog APIs independently.

The __() helper remains available for the familiar translation API, while the underlying functionality is also exposed through testable object-oriented services.

Validation

  • PHPUnit on PHP 8.3, 8.4 and 8.5;
  • PHP 8.3 prefer-lowest;
  • PHPStan;
  • Pint;
  • PHPMD with cyclomatic complexity threshold 5 and NPath threshold 50;
  • composer validate --strict;
  • DCO.

Add tool-agnostic source collection, deterministic JSON catalog IO,
placeholder validation, configurable localization loading, and stronger
cross-version test coverage.

Also repair the test fixtures after locale resolution started validating
configured locales.

Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos
vitormattos force-pushed the feat/translation-catalog-foundation branch from 23fa981 to 04df351 Compare September 26, 2026 15:12
vitormattos and others added 28 commits September 26, 2026 12:14
Handle escaped printf percents correctly, remove a PHPStan 2 option that no
longer exists, avoid Composer command-name collisions, and apply the Pint
format expected by the current toolchain.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Normalize not-operator spacing and PHPDoc alignment required by the current
Laravel Pint release.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Use explicit boolean comparisons around directory creation so the code remains
clear and stable across the current Pint rule set.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Always terminate generated JSON catalogs with LF instead of PHP_EOL so the
same catalog has identical bytes on Linux and Windows.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Temporarily surface Pint's exact formatting changes in CI so the branch can
be aligned with the current formatter without guessing fixer output.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Apply the formatter's exact constructor layout and restore the lint workflow
to non-mutating test mode.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Introduce locale-aware translation sources, pluggable extractors, safe catalog
path resolution and conservative catalog synchronization. Extraction filters
non-source locales before invoking adapters so translated content cannot pollute
the canonical source catalog.

Keep the implementation translation-tool agnostic and preserve the declared
PHP 8.0 runtime compatibility.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Use PHPUnit attributes for data providers and validate extractor output before
normalization so PHPStan can narrow the result type correctly.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Validate catalog values before writing and force object encoding so empty or
numeric-key catalogs never become JSON arrays.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Keep defensive checks for public-library callers while marking boundary values
as runtime mixed so PHPStan does not treat PHPDoc declarations as guarantees.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Temporarily export the resolved lockfile from the stable PHP 8.2 job so the
library CI can move to reproducible installs while retaining dedicated
compatibility jobs.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add a one-time branch workflow to materialize the development lockfile from
the package constraints before switching normal CI to composer install.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Use a real GitHub Actions matrix for supported PHP and operating-system
combinations, reserve composer update for the explicit prefer-lowest
compatibility job, enable Dependabot for Composer and Actions, update checkout
to v7.0.1 by full SHA, and expand placeholder coverage with data providers.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Temporarily let the existing test workflow create the first Composer lockfile
on this same-repository pull request. The bootstrap job is removed after the
lockfile is committed.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Track composer.lock so normal development and CI installs are reproducible.
The lockfile remains irrelevant to downstream consumers of this library.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Keep only the steady-state CI now that composer.lock is tracked: locked
installs for normal jobs and one explicit prefer-lowest compatibility job.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Move path resolution, JSON catalog encoding, placeholder parsing and extractor
result normalization into focused services. Keep public helpers as compatible
facades while reducing branching and IO coupling in the core classes.

Add direct unit coverage for each pure service and edge cases.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Wrap constructed locale resolvers before method chaining so the helpers parse
on every PHP runtime supported by the package.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add PHPMD with a cyclomatic-complexity threshold of 5 and an NPath guard,
run it in pull requests, and refresh development/tool lockfiles so static
analysis remains reproducible.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Move locale display-name resolution and URL-key mapping out of global helpers
into independently testable services with injectable name resolution.

Remove the temporary lock refresh workflow now that all development lockfiles
are committed.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Replace compound path-segment branching with a dedicated predicate and split
ExtractedString constructor validation into focused guards. Expand data-driven
coverage for required fields and invalid line numbers.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Move PHPStan and PHPMD into dedicated vendor-bin projects and make all tool
scripts invoke their isolated binaries explicitly. Keep the root require-dev
limited to the composer-bin plugin and Jigsaw integration dependency.

Extend Dependabot coverage to every isolated Composer manifest.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Keep only the steady-state Composer Bin Plugin setup now that the root and
per-tool lockfiles are committed.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Disable composer-bin proxy links and invoke PHPUnit and Pint directly from
their isolated vendor-bin projects. This keeps both dependencies and executable
entry points scoped to each development tool.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add a temporary branch workflow to update only Composer lock metadata after
disabling root bin links.

Signed-off-by: Vitor Mattos <vitor@php.rio>
github-actions Bot and others added 6 commits September 26, 2026 17:30
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Keep only the steady-state isolated Composer Bin Plugin configuration now that
the refreshed root lock metadata is committed.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Drop PHP 8.0-8.2 from the package contract and CI matrix. PHP 8.2 is already
security-only and reaches end of life at the end of 2026, so a newly modernized
library should start from PHP 8.3.

Move prefer-lowest and complexity validation to PHP 8.3 and update the
published requirements accordingly.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Keep only the steady-state PHP 8.3+ support policy now that the root lockfile
metadata reflects the new minimum runtime.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Replace the historical README with focused usage documentation for the current
package architecture. Remove obsolete badges, banner, TODOs, locale-format
assumptions and project-specific page-layout advice. Move contribution guidance
to CONTRIBUTING.md.

Signed-off-by: Vitor Mattos <vitor@php.rio>
vitormattos and others added 14 commits September 26, 2026 14:44
Run the supported PHP versions on Ubuntu only and keep the prefer-lowest job
separate. The package targets the Linux-based PHP/Jigsaw development workflow.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Restore the upstream MIT license text under the conventional LICENSE filename
so GitHub and package consumers can identify the repository license directly.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Replace the abandoned php-json-tongue runtime dependency with an injectable
LocalizationLoader contract and a strict JSON directory loader. Preserve the
historical per-locale and multi/ formats while rejecting malformed catalogs
instead of silently treating them as empty.

Add compatibility and custom-loader coverage so consuming Jigsaw projects can
replace storage without changing the Jigsaw integration.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add a temporary branch workflow to regenerate the development lockfile after
removing the abandoned php-json-tongue runtime dependency.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Split root and per-locale validation into focused methods instead of relaxing
the configured cyclomatic-complexity threshold.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add a temporary branch workflow to apply the repository's Pint rules to the
new loader implementation.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Document the storage extension point and remove temporary lock/formatting
workflows now that the loader refactor is committed and formatted.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Exercise LoadLocalization through Jigsaw's container to ensure the optional
loader contract does not require consumer bindings for the default setup.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Rename the Composer package to libresign/jigsaw-localization and migrate the
PHP namespace to LibreSign\\JigsawLocalization across source, tests, mocks and
documentation. Preserve original authorship and document the upstream fork.

Add package discovery metadata for Packagist and the maintained repository.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Add a temporary branch workflow to refresh Composer lock metadata after the
package and PSR-4 namespace rename.

Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Apply the repository import ordering rules after moving the package to the
LibreSign namespace and remove the temporary lock refresh workflow.

Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos vitormattos changed the title feat: add tool-agnostic translation catalog foundation feat: modernize Jigsaw localization package Sep 26, 2026
@vitormattos
vitormattos merged commit 0c0e08d into main Sep 28, 2026
8 checks passed
@vitormattos
vitormattos deleted the feat/translation-catalog-foundation branch September 28, 2026 19:12
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.

1 participant