jer*_*rry 6 java android localization quotation-marks
我之前为Swift 问了一个类似的问题,我现在面临着Android/Java中的同样问题.
Java中是否有一种方法可以为String 添加引号?引号应根据用户的语言设置正确本地化(请参阅https://en.wikipedia.org/wiki/Quotation_mark).文本在数据库中不带引号存储.我想TextView在添加引号后显示字符串.
例如:
String quote = "To be or not to be..."
// one or more lines of code that add localized quotation marks
// to the beginning and the end of the string
mMyTextView.setText(stringWithQuotes);
Run Code Online (Sandbox Code Playgroud)
对于法国用户:«成为或不成为......»
对于德国用户:"成为或不成为......"
对于英语(美国)用户:"成为或不成为...... "
我没有尝试过这个,但您也许可以使用Locale.getDefault。您可以为每个国家/地区创建一个具有不同报价的枚举,并在枚举中提供该枚举。然后,只需找到与枚举匹配的区域设置并替换指定区域设置的引号字符即可。
| 归档时间: |
|
| 查看次数: |
412 次 |
| 最近记录: |