Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Translation] Added support for translation files with other filename patterns#27655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| $expectedFileExtension =sprintf('%s.xlf',str_replace('-','_',$targetLanguage)); | ||
| $realFileExtension =explode('.',basename($file),2)[1] ??''; | ||
| $normalizedLocale =str_replace('-','_',$targetLanguage); | ||
| $expectedFilenamePattern =sprintf('/^(.*\.%s\.xlf|%s\..*\.xlf)/',$normalizedLocale,$normalizedLocale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missingpreg_quote on the 2 variables you inject in the regex
stof commentedJun 20, 2018
In a FrameworkBundle-based project, the file name format must always be |
javiereguiluz commentedJun 20, 2018
@stof I've made some changes. Please tell me if that's what you were proposing. Thanks. |
| $realFileExtension =explode('.',basename($file),2)[1] ??''; | ||
| $normalizedLocale =preg_quote(str_replace('-','_',$targetLanguage)); | ||
| // when this command is used inside Symfony, require filenames to be '____.locale.xlf' | ||
| // when used outside Symfony, allow '____.locale.xlf' and 'locale.____.xlf' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
comments should be talking about strict vs not strict, not aboutinside Symfony. Other projects may put the command in strict mode too.
| private$requireStrictFileNames; | ||
| publicfunction__construct(string$name =null,callable$directoryIteratorProvider =null,callable$isReadableProvider =null) | ||
| publicfunction__construct(string$name =null,callable$directoryIteratorProvider =null,callable$isReadableProvider =null,bool$requireStrictFileNames =false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Shouldn't we keep usingtrue as default, to keep the same behavior than today by default ?
| if (null !==$targetLanguage =$this->getTargetLanguageFromFile($document)) { | ||
| $expectedFileExtension =sprintf('%s.xlf',str_replace('-','_',$targetLanguage)); | ||
| $realFileExtension =explode('.',basename($file),2)[1] ??''; | ||
| $normalizedLocale =preg_quote(str_replace('-','_',$targetLanguage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
you need to pass the regex delimiter as second argument topreg_quote as it needs to be escaped too.
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can we add some more tests , especially whenrequireStrictFileNames is false?
fabpot commentedJun 25, 2018
Thank you@javiereguiluz. |
… other filename patterns (javiereguiluz)This PR was squashed before being merged into the 4.2-dev branch (closes#27655).Discussion----------[Translation] Added support for translation files with other filename patterns| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#27644| License | MIT| Doc PR | -This implements the#27644 feature request in case we accept it.My vote is 👍 because the changes required are tiny and the resulting code is even more robust thanks to the new `preg_match()` call.Commits-------0ee912d [Translation] Added support for translation files with other filename patterns
This implements the#27644 feature request in case we accept it.
My vote is 👍 because the changes required are tiny and the resulting code is even more robust thanks to the new
preg_match()call.