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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ To work with different translations you may want merge them in an unique file. T
```php
//Create a new Translations instances with our translations.

$translations1 = Gettext\Extractors\Po::extract('my-file1.po');
$translations2 = Gettext\Extractors\Po::extract('my-file2.po');
$translations1 = Gettext\Extractors\Po::fromFile('my-file1.po');
$translations2 = Gettext\Extractors\Po::fromFile('my-file2.po');

//Merge one inside other:
$translations1->mergeWith($translations2);
Expand All @@ -218,10 +218,10 @@ Example:
use Gettext\Translations;

//Scan the php code to find the latest gettext translations
$translations = Gettext\Extractors\PhpCode::extract('my-templates.php');
$translations = Gettext\Extractors\PhpCode::fromFile('my-templates.php');

//Get the translations of the code that are stored in a po file
$poTranslations = Gettext\Extractors\Po::extract('locale.po');
$poTranslations = Gettext\Extractors\Po::fromFile('locale.po');

//Apply the translations from the po file to the translations, and merges header and comments but not references and without add or remove translations:
$translations->mergeWith($poTranslations, Translations::MERGE_HEADERS | Translations::MERGE_COMMENTS);
Expand Down
22 changes: 22 additions & 0 deletions src/Extractors/Blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Gettext\Extractors;

use Gettext\Translations;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\Compilers\BladeCompiler;

/**
* Class to get gettext strings from blade.php files returning arrays
*/
class Blade extends Extractor implements ExtractorInterface
{
/**
* {@inheritDoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
$string = (new BladeCompiler(new Filesystem, null))->compileString($string);

return PhpCode::fromString($string, $translations, $file);
}
}