How to internationalize quotation marks in a JSP

此生再无相见时 提交于 2019-12-12 03:18:44

问题


I have an application where we are showing quotes from a client in a JSP. The actual text of the quotation is stored in a database and doesn't include the quotation marks.

The JSP currently has "{$bean.quote}" which, I pointed out to my boss, is not internationalizable.

I've got his approval to internationalize this, but I'm not sure what approach to use. My first one is to do an i18n lookup for startQuote and endQuote and store the character in the table. This feels heavy.

Ideas?


回答1:


That is one way to do it. But you're right; if you're doing it in a lot of places, it's going to be awkward to read and maintain.

HTML has a special element for this: q. So you can put this in your page:

<q>${bean.quote}</q>

You can then perform the internationalization in the CSS, as described in the Quotation marks section of the CSS specification:

q:lang(en) {
    quotes: '\201c' '\201d' "\2018" "\2019"
}
q:lang(no) {
    quotes: "\ab" "\bb" '"' '"'
}

q:before {
    content: open-quote;
}
q:after {
    content: close-quote;
}


来源:https://stackoverflow.com/questions/32873545/how-to-internationalize-quotation-marks-in-a-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!