schmittjoh / JMSTranslationBundle

Puts the Symfony2 Translation Component on steroids
http://jmsyst.com/bundles/JMSTranslationBundle
426 stars 292 forks source link

1.5 => simplexml_load_file() expects parameter 1 to be a valid path, object given #535

Closed picks44 closed 4 years ago

picks44 commented 4 years ago
Q A
Bundle version 1.5
Symfony version 3.4.38
PHP version 7.2

Here is the output I get when using the command

C:\laragon\bin\php\php-7.2.16-Win32-VC15-x64\php.exe C:\laragon\www\DESiwid\bin\console translation:extract cs_CZ --config=iwid --output-format=xliff
Extracting Translations for locale cs_CZ
Keep old translations: No
Output-Path: C:\laragon\www\DESiwid\app/../src/Des/IwidBundle/Resources/translat
ions
Directories: C:/laragon/www/DESiwid/app/../src/Des/IwidBundle, C:/laragon/www/DE
Siwid/app/Resources/TwigBundle
Excluded Directories: cache, data, logs, Api, Test, Tests
Excluded Names: # none #
Output-Format: xliff
Custom Extractors: jms_i18n_routing
============================================================
Loading catalogues from "C:\laragon\www\DESiwid\app/../src/Des/IwidBundle/Resour
ces/translations"
15:26:24 ERROR     [console] Error thrown while running command "translation:ext
ract cs_CZ --config=iwid --output-format=xliff". Message: "simplexml_load_file()
 expects parameter 1 to be a valid path, object given" ["exception" => TypeError
 { …},"command" => "translation:extract cs_CZ --config=iwid --output-format=xlif
f","message" => "simplexml_load_file() expects parameter 1 to be a valid path, o
bject given"]

In XliffLoader.php line 40:

  Type error: simplexml_load_file() expects parameter 1 to be a valid path, o  
  bject given                                                                  

translation:extract [--enable-extractor ENABLE-EXTRACTOR] [--disable-extractor D
ISABLE-EXTRACTOR] [-c|--config CONFIG] [-b|--bundle BUNDLE] [--exclude-name EXCL
UDE-NAME] [--exclude-dir EXCLUDE-DIR] [-i|--ignore-domain IGNORE-DOMAIN] [--doma
in DOMAIN] [-d|--dir DIR] [--output-dir OUTPUT-DIR] [--dry-run] [--output-format
 OUTPUT-FORMAT] [--default-output-format DEFAULT-OUTPUT-FORMAT] [--keep] [--exte
rnal-translations-dir EXTERNAL-TRANSLATIONS-DIR] [-h|--help] [-q|--quiet] [-v|vv
|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--
env ENV] [--no-debug] [--] <command> [<locales>]...

Process finished with exit code 255.

It was working file with 1.4.4, please support.

goetas commented 4 years ago

solved already in https://github.com/schmittjoh/JMSTranslationBundle/pull/533

picks44 commented 4 years ago

Cool @goetas thanks, is it already available in a release or shall I wait to upgrade the package?

goetas commented 4 years ago

Already released as 1.5.1

On Thu, 19 Mar 2020, 08:43 VinZ, notifications@github.com wrote:

Cool @goetas https://github.com/goetas thanks, is it already available in a release or shall I wait to upgrade the package?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schmittjoh/JMSTranslationBundle/issues/535#issuecomment-601033510, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF5UJ5AK77W5CH7WBNS3M3RIHEKLANCNFSM4LOUE4KA .

picks44 commented 4 years ago

OK, now I have this error on the same command (with package updated to 1.5.1). Any clue @goetas ?

08:19:49 ERROR     [console] Error thrown while running command "translation:ext
ract en --config=iwid --output-format=xliff". Message: "hash() expects parameter
 2 to be string, integer given" ["exception" => TypeError { …},"command" => "tra
nslation:extract en --config=iwid --output-format=xliff","message" => "hash() ex
pects parameter 2 to be string, integer given"]
goetas commented 4 years ago

Seems that some of your translation keys are just numbers, is it?

On Thu, 19 Mar 2020, 09:21 VinZ, notifications@github.com wrote:

OK, now I have this error on the same command (with package updated to 1.5.1). Any clue @goetas https://github.com/goetas ?

08:19:49 ERROR [console] Error thrown while running command "translation:ext

ract en --config=iwid --output-format=xliff". Message: "hash() expects parameter

2 to be string, integer given" ["exception" => TypeError { …},"command" => "tra

nslation:extract en --config=iwid --output-format=xliff","message" => "hash() ex

pects parameter 2 to be string, integer given"]

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schmittjoh/JMSTranslationBundle/issues/535#issuecomment-601047855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF5UJZWTICO7U4V3GG2LUTRIHIZ3ANCNFSM4LOUE4KA .

picks44 commented 4 years ago

@goetas The closest TK that I have that looks like an integer is "615 xxx xxx x"... it is a placeholder in a form.

franmomu commented 4 years ago

can you please try to add a string casting in the second parameter of the hash function? in https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Translation/Dumper/XliffDumper.php#L121, like this:

$unit->setAttribute('id', hash('sha1', (string) $id));

And see if there are more errors please?

picks44 commented 4 years ago

Tested and validated, thanks guys!