php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 132 forks source link

Add configuration for location of strings in Scanner #256

Closed Arzaroth closed 4 years ago

Arzaroth commented 4 years ago

This addresses both #208 and #143

I didn't provide tests for this PR since there is no concrete implementation of CodeScanner in this repository

oscarotero commented 4 years ago

Hi, thanks for your work with these issues!

I'd rather have these two issues in two different pull requests, because I have some doubts:

$contents = file_get_contents($file);
$relativePath = get_the_relative_path($file);

$translations = $scanner->scanString($contents, $relativePath);

This function is already present in the interface (https://github.com/php-gettext/Gettext/blob/master/src/Scanner/ScannerInterface.php#L21) and this way is much more flexible, so I'd wouldn't add this feature (at least, for now).

Arzaroth commented 4 years ago

Points taken.

I'll close this PR and submit two new ones.

Regarding relative paths, I didn't realize what you suggested was possible. It is indeed a nice workaround and I understand your argument on this matter.