【问题标题】:Is there a way to make gettext comment extractor look for the inline comments of a string rather than the line before?有没有办法让 gettext 注释提取器查找字符串的内联注释而不是之前的行?
【发布时间】:2021-04-16 22:09:27
【问题描述】:

这是我的代码的一个小sn-p:

#SUBTRACTION
       elif _("sub") in calc: #FOR TRANSLATORS: This is a translated if statement. Dont add accents. Use a key part of the word e.g. sub instead of subtract instead of the full word if possible.
           misc.showUserWhatIThink(_("subtract a number from a number"))
           TheBasics.subtraction()

Poedit (gettext) 会将注释 FOR TRANSLATORS: This is a translated if statement. [...] 分配给 subtract a number from a number 而不是 sub。我希望“sub”的注释出现在“翻译注释”部分。

有什么办法可以规避吗?我已经一遍又一遍地添加了相同的评论;我不想重做所有这些。

【问题讨论】:

    标签: python python-3.x internationalization gettext poedit


    【解决方案1】:

    这是不可能的。

    而且由于需要对提取器逻辑进行重大更改以使评论放置更加灵活,因此这种情况不太可能发生变化。

    如果它对您来说是关键任务:使用一个小脚本预解析您的源代码,如果您找到 #TRANSLATORS cmets,请将它们提取到 _() 调用上方的一行中。

    【讨论】:

    • 恼人的 gettext 并不意味着灵活。 ://
    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 2015-06-26
    相关资源
    最近更新 更多