Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:masterfromjaviereguiluz:fix_27644
Jun 25, 2018

Conversation

@javiereguiluz
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#27644
LicenseMIT
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 newpreg_match() call.

@javiereguiluzjaviereguiluz added this to thenext milestoneJun 20, 2018
@nicolas-grekasnicolas-grekas changed the titleAdded support for translation files with other filename patterns[Translation] Added support for translation files with other filename patternsJun 20, 2018
$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);
Copy link
Member

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
Copy link
Member

In a FrameworkBundle-based project, the file name format must always be<domain>.<locale>.<format>. Anything else is unsupported (because the bundle needs to be able to extract the domain and the locale from the file name). So having the convention configurable in the command (using a constructor argument) would be better to me than supporting having the locale anywhere in the file name (which would not report all issues for Symfony projects)

DanielSiepmann and jvasseur reacted with thumbs up emoji

@javiereguiluz
Copy link
MemberAuthor

@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'
Copy link
Member

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)
Copy link
Member

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));
Copy link
Member

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.

Copy link
Member

@fabpotfabpot left a 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
Copy link
Member

Thank you@javiereguiluz.

@fabpotfabpot merged commit0ee912d intosymfony:masterJun 25, 2018
fabpot added a commit that referenced this pull requestJun 25, 2018
… 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
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof requested changes

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@javiereguiluz@stof@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp