【问题标题】:What does the number after //$NON-NLS- mean//$NON-NLS- 后面的数字是什么意思
【发布时间】:2013-08-07 21:40:12
【问题描述】:

这是一个后续问题:What does $NON-NLS-1$ mean?

我注意到,当您使用任何数字时,comment 标记都会被识别为 NLS 标记。但是,只有数字 1 似​​乎正确修复了警告。 (无声警告 vs. 无声警告 + 不必要的 nls 标签)

这样做的目的是什么?

【问题讨论】:

    标签: java eclipse internationalization


    【解决方案1】:

    $NON-NLS- 后面的数字表示标记用于标记行上的哪个字符串。数字 1 适合您,可能是因为您尝试标记的行上只有 1 个字符串。

    如果您在同一行中有 2 个字符串,例如,您可以使用 $NON-NLS-2$ 仅标记第二个字符串。

    //Warning on "baz"
    foo("bar","baz"); //$NON-NLS-1$
    
    //Warning on "bar"
    foo("bar","baz"); //$NON-NLS-2$
    
    //No warnings
    foo("bar","baz"); //$NON-NLS-1$  //$NON-NLS-2$
    
    //Warning on "baz" (apparently the slashes are required even with multiple tags)
    foo("bar","baz"); //$NON-NLS-1$  $NON-NLS-2$
    

    【讨论】:

    • 如果你想禁止所有字符串文字警告,你可以使用@SuppressWarnings("nls")
    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 2023-01-19
    • 2013-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多