andersundsehr / grumphp-xliff-task
GrumPHP task to lint xlf/xliff Files
Package info
github.com/andersundsehr/grumphp-xliff-task
pkg:composer/andersundsehr/grumphp-xliff-task
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
- ext-dom: *
- phpro/grumphp: ^2.0.0
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
pluswerk/grumphp-xliff-task
A GrumPHP task that lints XLIFF translation files (.xlf), as TYPO3 uses them. Besides the XML syntax it checks the structure that TYPO3 expects in source and translation files.
This task is part of
pluswerk/grumphp-config. If you use that package, the task is already installed and configured.
Requirements
- PHP 8.2 or newer with the
domextension - GrumPHP 2
Installation
composer require --dev pluswerk/grumphp-xliff-task
Register the extension and the task in your grumphp.yml:
grumphp: tasks: xlifflint: ignore_patterns: [] load_from_net: false x_include: false dtd_validation: false scheme_validation: false triggered_by: [xlf] extensions: - PLUS\GrumPHPXliffTask\ExtensionLoader
Options
The options match those of GrumPHP's xmllint task.
| Option | Default | Meaning |
|---|---|---|
ignore_patterns |
[] |
Paths to skip: plain strings that a path must contain, or regular expressions delimited with / |
load_from_net |
false |
Allow loading DTD and XSD files from the internet |
x_include |
false |
Resolve XInclude references before checking |
dtd_validation |
false |
Validate against the DTD that the file declares |
scheme_validation |
false |
Validate against the XSD schema that the file declares |
triggered_by |
[xlf] |
File extensions to check |
What is checked
- The file is well-formed XML (and valid against its DTD or schema, if enabled).
- No
<file>element uses the deprecatedtargetattribute. Usetarget-languageinstead. - In a source file, where
<file>has notarget-language, every<trans-unit>has anidattribute and a<source>element, and no<target>element. - In a translation file, where
<file>has atarget-language, every<trans-unit>has anidattribute and a<target>element.
Every finding fails the task, including a <target> in a source file, which is reported as a warning.
Source file, e.g. locallang.xlf:
<?xml version="1.0" encoding="UTF-8"?> <xliff version="1.0"> <file source-language="en" datatype="plaintext" original="messages" product-name="extension"> <header/> <body> <trans-unit id="button.save"> <source>Save</source> </trans-unit> </body> </file> </xliff>
Translation file, e.g. de.locallang.xlf:
<?xml version="1.0" encoding="UTF-8"?> <xliff version="1.0"> <file source-language="en" target-language="de" datatype="plaintext" original="messages" product-name="extension"> <header/> <body> <trans-unit id="button.save"> <target>Speichern</target> </trans-unit> </body> </file> </xliff>
Upgrading from the AUS version
Older versions were published as andersundsehr/grumphp-xliff-task with the namespace AUS. Change the extension in your grumphp.yml:
grumphp: extensions: # before: AUS\GrumPHPXliffTask\ExtensionLoader - PLUS\GrumPHPXliffTask\ExtensionLoader
If your grumphp.yml still lists tasks and extensions under parameters:, move them under grumphp:; GrumPHP 1.0 and newer only read them there.
Contributing
This package is developed in the monorepo andersundsehr/grumphp-config. Please open issues and pull requests there.
License
with ♥️ from anders und sehr GmbH
If something did not work 😮
or you appreciate this Extension 🥰 let us know.
We are hiring https://www.andersundsehr.com/karriere/