Skip to content

Commit

Permalink
Add readme and example xhtml-file
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Dec 19, 2023
1 parent d1a990d commit 6cc9890
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tal-i18n-extract

[![Unittests](https://github.com/usox/tal-i18n-extract/actions/workflows/php.yml/badge.svg)](https://github.com/usox/tal-i18n-extract/actions/workflows/php.yml)

Extract translation keys out of [PHPTAL](https://github.com/phptal/PHPTAL) templates.

This is a php port of the [I18NFool](https://metacpan.org/dist/I18NFool) CPAN perl-package.

## Usage

```php
./bin/tal-i18n-extract path-to-file(s).xhtml
```

All found translation keys will be printed out POT-formatted.

## Beware

All templates must contain valid xml and have to define the i18n-namespace (see example).
8 changes: 8 additions & 0 deletions example/example.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<div i18n:translate="">Some string</div>
<div i18n:translate="">Some string with <span i18n:name="placeholder">what?!</span></div>
<div i18n:translate="translation-key">Some string with pre-defined translation-key</div>
<div title="Some title-attribute" i18n:attributes="title">...</div>
<div title="Some title-attribute" i18n:attributes="title pre-defined-attribute-translation-key">...</div>
</root>
1 change: 0 additions & 1 deletion src/Io/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use DOMDocument;
use DOMXPath;
use Generator;
use Usox\TalI18nExtract\ExtractorDecorator;

/**
* Gets file-paths and returns fully-loaded XPath-objects one-by-one
Expand Down
2 changes: 1 addition & 1 deletion tests/Io/FileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testReadFailsIfFileDoesNotExist(): void

public function testReadFailsIfFileIsNotReadable(): void
{
$file = new vfsStreamFile('snafu', 0000);
$file = new vfsStreamFile('snafu', 0o000);

$this->vfsStream->addChild($file);

Expand Down

0 comments on commit 6cc9890

Please sign in to comment.