我问了一个similar question较早的 Swift,我现在在 Android/Java 中面临同样的问题。
在 Java 中有没有办法为字符串添加引号?引号应根据用户的语言设置正确本地化(请参阅 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);
对于法国用户:«成为或不成为……»
对于德国用户:“成为或不成为……”
对于英语(美国)用户:“To be or not to be...”
最佳答案
我没试过,但你可以使用 Locale.getDefault .您可以为每个具有不同报价的国家/地区创建一个枚举,并在枚举中提供该枚举。然后只需找到与枚举匹配的语言环境并替换指定语言环境的引号字符即可。
关于java - 在 Java 中添加引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39005059/