希伯来语

时间:2017-01-25 11:09:21

标签: android locale translation hebrew

我的应用程序已翻译成希伯来语,西班牙语,英语,加泰罗尼亚语和匈牙利语。 除希伯来语外,所有语言都很有效。

代码在此行显示lint错误: lblUsername.setText(getString(R.string.welcome, mUserModel.getUserName()));

翻译如下: strings.xml为英文 <string name="welcome">Welcome, %s</string>

希伯来语的strings.xml <string name="welcome">"ברוך/ה הבא/ה, s%\"</string>

当我在我的设备上运行设置了英语语言环境的应用程序时,它运行正常。与其他语言相同。但在希伯来语中我得到了这个错误:

java.lang.RuntimeException: Unable to resume activity {be.iminds.mresist/be.iminds.mresist.activities.MainActivity}: java.util.UnknownFormatConversionException: Conversion: 
                                                                       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
                                                                       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
                                                                       at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                       at android.os.Looper.loop(Looper.java:148)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                    Caused by: java.util.UnknownFormatConversionException: Conversion: 
                                                                       at java.util.Formatter$FormatSpecifierParser.unknownFormatConversionException(Formatter.java:2321)
                                                                       at java.util.Formatter$FormatSpecifierParser.advance(Formatter.java:2315)
                                                                       at java.util.Formatter$FormatSpecifierParser.parseConversionType(Formatter.java:2394)
                                                                       at java.util.Formatter$FormatSpecifierParser.parseArgumentIndexAndFlags(Formatter.java:2365)
                                                                       at java.util.Formatter$FormatSpecifierParser.parseFormatToken(Formatter.java:2298)
                                                                       at java.util.Formatter.doFormat(Formatter.java:1071)
                                                                       at java.util.Formatter.format(Formatter.java:1042)
                                                                       at java.util.Formatter.format(Formatter.java:1011)
                                                                       at java.lang.String.format(String.java:1554)
                                                                       at android.content.res.Resources.getString(Resources.java:430)
                                                                       at android.content.Context.getString(Context.java:425)
                                                                       at be.iminds.mresist.activities.MainActivity.init(MainActivity.java:187)
  ...

为什么这适用于其他语言但不适用于希伯来语?

1 个答案:

答案 0 :(得分:0)

翻译字符串中的%应出现在s之前而不是之后。我也不确定你为什么添加反斜杠。

替换

<string name="welcome">"ברוך/ה הבא/ה, s%\"</string>

<string name="welcome">"ברוך/ה הבא/ה, %s"</string>