Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check translator comments with clang-tidy #34243

Merged
merged 1 commit into from Sep 27, 2019

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Sep 26, 2019

Summary

SUMMARY: Build "Check translator comments with clang-tidy"

Purpose of change

Translator comments need to be preceding the extracted string and on the same or adjacent line to be properly recognized by xgettext. However, sometimes the translation calls need to be split into multiple lines due to styling, and newly added code can also unintentionally separate the comments from the extracted string. Because this kind of errors are not always obvious, this PR adds a clang-tidy check to check translator comments that does not have a matching string.

Describe the solution

Translator comments and macros are first recorded. AST matchers are then used to match strings in translation function calls and macros. Comments correctly preceding the found strings are then marked. After all strings are processed, unmarked comments are considered to be misplaced, and reported as errors.

Describe alternatives you've considered

A regex solution would be complicated and hard to maintain, due to the fact that a translator comment can be positioned after the translation function and before the extracted string.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Translation I18n labels Sep 26, 2019
@ZhilkinSerg ZhilkinSerg merged commit 1236ad2 into CleverRaven:master Sep 27, 2019
@Qrox Qrox deleted the translator-comments-check branch September 27, 2019 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Translation I18n
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants