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 a lint:xliff command for XLIFF files#21578

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

Closed

Conversation

@javiereguiluz
Copy link
Member

@javiereguiluzjaviereguiluz commentedFeb 10, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#19942
LicenseMIT
Doc PR-

It works exactly the same as thelint:yaml command:

Lint a single file

single-file

Lint a bundle

bundle

Get the result in JSON

json

chalasr and ogizanagi reacted with thumbs up emoji
if (-1 === $error->line) {
$errorMessages[] = $error->message;
} else {
$errorMessages[] = sprintf('Line %d, Column %d: %s', $error->line, $error->column, trim($error->message));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

in JSON, it may be better to have the line and column as separate properties:{ line: 10, column: 5, message: "unexpected char"}.
It would make the output more useful by allowing to known the location without parsing the error message.

you could do it by building such an array here, and doing the sprintf only indisplayTxt. In this case, I would keep the same structure for general errors, but withnull for the line and column.

Wirone reacted with thumbs up emoji
Copy link
Member

@chalasrchalasrFeb 10, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could be interesting to port this change on other lint commands for consistency (yaml, twig)

ogizanagi reacted with thumbs up emoji
*/
public function isEnabled()
{
return class_exists(BaseLintCommand::class) && parent::isEnabled();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

the parent logic is justreturn true, so it is not really necessary.

@javiereguiluz
Copy link
MemberAuthor

Note: I've called this commandlint:translation instead oflint:xliff orlint:xlf because, in the future, the idea would be to keep adding linting features related to translation ... and maybe not directly related to XLIFF.

@nicolas-grekasnicolas-grekas added this to the3.3 milestoneFeb 11, 2017
@nicolas-grekas
Copy link
Member

do we have any plan for other formats? if not, I'm not sure about the name.
"linting" is about some specific language - so having the name of the actual linted language in the command looks good to me.

javiereguiluz reacted with thumbs up emoji

@javiereguiluzjaviereguiluz changed the title[Translation] Added a lint:translation command for XLIFF files[Translation] Added a lint:xliff command for XLIFF filesFeb 12, 2017
Copy link
Contributor

@phansysphansys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Status: Needs work.

$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
$io->listing(array_map(function ($error) {
// general document errors have a '-1' line number
return -1 === $error['line'] ? $error['message'] : sprintf('Line %d, Column %d: %s', $error['line'], $error['column'], $error['message']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If "-1" will be not allowed as line number, "%u" is more suitable as type specifier. The same applies for column.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

At the moment, the-1 value is not used ... but this could change at any moment, so let's keep it safe with the%d syntax.

}
}

if ($erroredFiles === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please, use Yoda condition.

javiereguiluz reacted with thumbs up emoji
Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great. Thank you for this PR. I like it and it sure is needed.

I have briefly reviewed the code and I have run tests on my application.

May I ask you to extract thevalidate function to a separate class? That would make it easier for third party libraries to re-use the validation logic.

@javiereguiluz
Copy link
MemberAuthor

Thanks for the reviews. About extracting thevalidate() method:

  • It's not the common practice in the other linters
  • For interoperability, the idea would be to executelint:xliff --format=json
  • However, I'd love if linters would be easier to use (for example like this ->[Yaml] Add bin/lint for using the LintCommand #19916 which sadly was refused)

So ... I don't know what to do.

@fabpot
Copy link
Member

Thank you@javiereguiluz.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@NyholmNyholmNyholm left review comments

@stofstofstof requested changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@phansysphansysphansys requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

8 participants

@javiereguiluz@nicolas-grekas@fabpot@stof@phansys@Nyholm@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp