2012-01-30 73 views
0

我不是程序員,但我想用gettext來幫助翻譯用vala編寫的項目(http://live.gnome.org/Vala/Tutorial)。當我必須使用佔位符重新排列句子的某些部分時,我遇到了一個問題。如何使用gettext佔位符?

例子:

public void show_retrieving_similars() { 
    if(hint != ViewWrapper.Hint.SIMILAR || lm.media_info.media == null) 
     return; 

    errorBox.show_icon = false; 
    errorBox.setWarning("<span weight=\"bold\" size=\"larger\">" + _("Loading similar songs") + "</span>\n\n" + _("BeatBox is loading songs similar to") + " <b>" + lm.media_info.media.title.replace("&", "&amp;") + "</b> by <b>" + lm.media_info.media.artist.replace("&", "&amp;") + "</b> " + _("..."), null); 
    errorBox.show(); 
    list.hide(); 
    albumView.hide(); 
    similarsFetched = false; 
} 

什麼我需要做什麼?

+0

你或許應該報告爲這一項目提供的bug你正在翻譯。 – ptomato 2012-02-01 09:00:27

回答

0

我沒有用過VALA,我沒有測試此,它看起來像你需要更換

errorBox.setWarning("<span weight=\"bold\" size=\"larger\">" + _("Loading similar songs") + "</span>\n\n" + _("BeatBox is loading songs similar to") + " <b>" + lm.media_info.media.title.replace("&", "&amp;") + "</b> by <b>" + lm.media_info.media.artist.replace("&", "&amp;") + "</b> " + _("..."), null); 

string title = lm.media_info.media.title.replace("&", "&amp;"); 
string artist = lm.media_info.media.artist.replace("&", "&amp;"); 
errorBox.setWarning(@"<span weight=\"bold\" size=\"larger\">Loading similar songs</span>\n\n BeatBox is loading songs similar to<b> $title </b>by<b> $artist </b>...", null);