Re: catching translation problems with pylint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> If we can detect these, then yeah, catch 'em. For the first one,
> that would also apply to the class-level strings, which we have a
> lot of in the GUI spokes. I think they're all N_, but it'd be nice
> to be sure.

If it's an an AST, we can check it.

> Would it be appropriate to check for markup strings through pylint?
> This one's a little complicated since sometimes we want markup, but
> only if it's applied to a part of the translatable string. I think
> the regex we'd want to reject as a bad translatable string is
> something like (here comes some angle brackets):
> '^(<[^>]*>)+[^<]*(</[^>]*>)+$'  It's not perfect, but anything that
> looks that much like a markup string probably has something going
> wrong, anyway. The idea being:
> 
> >> print re.match('^(<[^>]*>)+[^<]*(</[^>]*>)+$', '<span
> font-desc="whatever">Markup applies to whole string</span>')
> <_sre.SRE_Match object at 0x7f0ff33db360>
> >>> print re.match('^(<[^>]*>)+[^<]*(</[^>]*>)+$', '<span
> font-desc="whatever"><b>Markup still applies to whole
> string</b></span>')
> <_sre.SRE_Match object at 0x7f0ff33db3e8>
> >>> print re.match('^(<[^>]*>)+[^<]*(</[^>]*>)+$', '<span
> font-desc="whatever">Markup applies to <b>part</b> of the
> string</span>')
> None

Aside from my horror at you coming pretty close to attempting to parse
with a regex, yes we could probably do that.  The default pylint checks
do all sorts of crazy things.

> Also don't forget the other translate functions for the _("blah blah
> %s" % "blah") check: C_ and CN_ would work the same way (you can
> just ignore the context argument), and for P_ and CP_ the rule
> applies to both the msgid and msgplural arguments (first and second
> args on P_, second and third args on CP_).

All I'm doing is any time a "%" node is hit in the AST, I jump up and
look at what the parent node is.  If it's _, N_, etc. then we have a
problem.  So I think I don't have to do anything more complicated than
just add more functions to the list.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list




[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux